If your sitemap URLs only change when you deploy, you don't need to ship sitemap generation code to production. The zeroRuntime option generates sitemaps at build time and tree-shakes the generation code from your server bundle.
To enable zero runtime, add the following to your config:
export default defineNuxtConfig({
sitemap: {
zeroRuntime: true
}
})
When enabled, the module will automatically add /sitemap.xml to your prerender routes. The sitemap will be generated during build and served as a static file at runtime.
With zeroRuntime: true:
nitro.prerender.routesimport.meta.prerenderZero runtime mode still works in development (nuxt dev). The sitemap generation code runs normally during development so you can test your configuration.
Enabling zeroRuntime reduces the server bundle by approximately:
This is the sitemap generation code (XML building, URL normalization, source fetching) being tree-shaken from the bundle.
Zero runtime is ideal when:
nuxt generate for a fully static siteAvoid zero runtime when: