Nuxt API

'sitemap:prerender:done'

Type: (ctx: { options: ModuleRuntimeConfig, sitemaps: { name: string, readonly content: string }[] }) => void | Promise<void>

Called after sitemap prerendering completes. Useful for modules that need to emit extra files based on the generated sitemaps.

Context:

  • options - The resolved module runtime configuration
  • sitemaps - Array of rendered sitemaps with their route name and XML content (content is lazily loaded from disk)
nuxt.config.ts
export default defineNuxtConfig({
  hooks: {
    'sitemap:prerender:done': async ({ sitemaps }) => {
      // Log sitemap info
      for (const sitemap of sitemaps) {
        console.log(`Sitemap ${sitemap.name}: ${sitemap.content.length} bytes`)
      }
    }
  }
})
This hook only runs at build time during nuxt generate or nuxt build with prerendering enabled.
Did this page help you?