How to make Nuxt.js SSR with partially static pre-rendering pages

samchuang

There are a lot of information either on Nuxt SSR, or going full static, but I can't find any guide how to build a hybrid SSR with static pages together.

I'm building a website with Nuxt SSR, and I want to pre-render all product pages statically from a 10MB JSON file.

I found an archived thread on Reddit, mentioned it's possible to create a middleware with the routes to be statically generated. I don't know how to achieve that, and hope I can get some help.

kissu

You will probably need to join the Nuxt Discord but this is how you could achieve it: first note that this is not an official way of doing things and we'll have something better coming out very soon. but if you really need this a workaround is as follows:

  • set target: 'server' (not static)
  • run nuxt build to create your ssr bundle
  • run nuxt generate --no-build (ideally set your routes via generate.routes in your nuxt config)
  • copy the generated dist folder contents into your static folder (or serve directly from your web server config)
  • nuxt start

Source: https://discord.com/channels/473401852243869706/473406004751499275/886642260677124166

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to combine static and client side rendered pages in Nuxt.js?

How can I turn off SSR for only certain pages in Nuxt.js to use them as SPA application?

how to make a compressed js files with all pages in nuxt js

How to use SSR with Nuxt.js on Netlify

How do I get Nuxt.js to pre-render the full HTML for pages?

How do I handle passport js redirects from Nuxt SSR?

react,js component rendering partially

How to pre-render pages in static HTML for an Angular app?

How to make Jetty dynamically load "static" pages

How to make WolframAlpha Request on static Github Pages?

localStorage in Nuxt js is not working in SSR mode

How to pass the data to vue from node.js, in nuxt.js ssr?

target: 'static' does not pre-render in nuxt

How does Nuxt.js Server Side Rendering Work?

how to add plugins of ckeditor in nuxt with ssr

How to generate txt & xml files in nuxt SSR?

NUXT SSR on Vercel (zeit now). How to deploy?

How to get rid of CORS error in Nuxt/SSR?

How to import .js files from static in Nuxt.js

How to share variable with Nuxt.js from layout to pages?

How to disable route pre-rendering in Next.js?

Why am I getting resource 404s on static nuxt.js app hosted on GitHub pages?

Express.js to EJS rendering data partially

Calling Nuxt JS static files

How to make turn.js pages "clickable"

Rails Routing Clash When Rendering Static Pages

Deploying SSR Nuxt.js on AWS Lambda with Cloudflare?

Await for Action to finish with Async/Await in Nuxt.js (SPA, no SSR)

Base64 encoding/decoding in Nuxt.js with TypeScript and SSR