Hybrid rendering and nuxt generate
The official documentation for routeRules says that hybrid rendering shouldn't work with nuxt generate [1] but it seems to work fine.
Note that Hybrid Rendering is not available when using nuxt generate.
routeRules: {
"/": { prerender: true },
"/rules": { ssr: false },
"/profile": { ssr: false },
"/login": { ssr: false },
"/dashboard": { ssr: false },
"/table": { ssr: false },
},
When I run npm run generate, it correctly pre-renders only my index (landing) page. What does "is not available when using nuxt generate" mean here?
References:
[1] https://nuxt.com/docs/4.x/guide/concepts/rendering#route-rules
2 Replies
Hi @jakub. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Short answer: With nuxt generate you only get static HTML output, so only the prerender aspect of routeRules applies. Other hybrid behaviors (like per-route SSR toggling, ISR/SWR caching, headers, redirects, middleware, etc.) require a Nitro server and are not active with generate.
- nuxt generate prerenders routes to plain HTML and ships no server. That’s why server endpoints and server-driven routeRules can’t run; only static prerendered pages are produced (.output/public) (Universal Rendering).
- Hybrid rendering (routeRules such as ssr, swr/isr, headers, redirects, appMiddleware) is a Nitro server feature. It is not available with nuxt generate; you must use nuxt build to deploy with a server or edge/runtime to benefit from those rules (Hybrid Rendering, Server > Hybrid Rendering).
- prerender: true in routeRules can still influence which routes are statically generated (and recent fixes even infer prerender from matching routeRules for pages), but that’s still just static output, not runtime hybrid rendering (fix uses routeRules to hint prerender, Prerendering > Selective Pre-rendering). So your observation is expected: nuxt generate honors prerender and produces only the landing page. The “not available” note means the other hybrid behaviors in routeRules won’t apply without a server. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
- Hybrid rendering (routeRules such as ssr, swr/isr, headers, redirects, appMiddleware) is a Nitro server feature. It is not available with nuxt generate; you must use nuxt build to deploy with a server or edge/runtime to benefit from those rules (Hybrid Rendering, Server > Hybrid Rendering).
- prerender: true in routeRules can still influence which routes are statically generated (and recent fixes even infer prerender from matching routeRules for pages), but that’s still just static output, not runtime hybrid rendering (fix uses routeRules to hint prerender, Prerendering > Selective Pre-rendering). So your observation is expected: nuxt generate honors prerender and produces only the landing page. The “not available” note means the other hybrid behaviors in routeRules won’t apply without a server. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@1388891624649654332> Kapa.ai is still learning and improving, please let me know how I did by reacting below.