Performance: Static site generation with Nuxt
Static site generation improves page load speed by pre-building HTML pages, reducing server work and client rendering time.
export default { target: 'static', ssr: true /* enable static site generation */ }
export default { ssr: false /* client-side rendering only */ }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side rendering only | Many DOM updates after JS loads | Multiple reflows during hydration | High paint cost due to delayed content | [X] Bad |
| Static site generation with Nuxt | Minimal DOM updates on load | Single reflow on initial paint | Low paint cost with immediate content | [OK] Good |
target: 'static' to enable static site generation.ssr: false disables server-side rendering but does not enable static generation; mode is deprecated; buildModules with '@nuxt/static' is invalid.nuxt generate?
export default {
target: 'static',
generate: {
dir: 'public'
}
}generate.dir option sets the output folder for static files.dir: 'public' is set, the static files will be generated inside a folder named 'public'.nuxt generate but your dynamic routes are missing from the static site. What is the likely cause?generate.routes to pre-build them.target: 'server' disables static generation but does not explain missing dynamic routes if static is used; Nitro preset is internal; ssr: false disables SSR but not related to dynamic routes generation.generate.routes -> Option AasyncData fetches posts during build, enabling static generation.generate.routes tells Nuxt to pre-build each post page as static HTML.ssr: false disables server rendering; fetch() without generate.routes won't pre-build dynamic pages.Pass the test and this pattern moves unknown