Core Concepts

Zero Runtime

Last updated by Harlan Wilton in feat: `zeroRuntime` mode (#532).

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.

Usage

To enable zero runtime, add the following to your config:

nuxt.config.ts
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.

How it Works

With zeroRuntime: true:

  1. Sitemap routes are automatically added to nitro.prerender.routes
  2. Server handlers use dynamic imports gated by import.meta.prerender
  3. At build time, the sitemap generation code is tree-shaken from the runtime bundle
  4. Static XML files are served directly without any sitemap code execution

Development Mode

Zero runtime mode still works in development (nuxt dev). The sitemap generation code runs normally during development so you can test your configuration.

Benchmarks

Enabling zeroRuntime reduces the server bundle by approximately:

  • ~50KB uncompressed
  • ~5KB gzip

This is the sitemap generation code (XML building, URL normalization, source fetching) being tree-shaken from the bundle.

Limitations

  • Runtime sitemap generation is not available - sitemaps are only generated during build
  • Dynamic data sources that require runtime fetching won't work
  • Debug endpoints are disabled in zero runtime mode

When to Use

Zero runtime is ideal when:

  • Your pages only change when you commit and deploy
  • You're using nuxt generate for a fully static site
  • You want to minimize your server bundle size for edge/serverless

When Not to Use

Avoid zero runtime when:

  • Your CMS updates content without redeploying
  • You have user-generated content that changes frequently
  • Your sitemap URLs depend on runtime data
Did this page help you?