Docs Hub

🇮🇷
iran mirrors
LaravelLaravelLivewireLivewireAlpine.jsAlpine.jsNext.jsNext.jsVue.jsVue.jsZustandZustandNuxt.jsNuxt.jsFilamentFilament
BootstrapBootstrap
Nest.jsNest.js
ReactReact
Vite.jsVite.js
Tailwind CSSTailwind CSS

© 2026 Juza66 and Arash Fadaee

Docs Hub

🇮🇷 iran mirrors
AfterCacheLifeCacheTagCatchErrorConnectionCookiesDraft ModeFetchForbiddenGenerate Image MetadataGenerate MetadataGenerate SitemapsGenerate Static ParamsGenerate ViewportHeadersImage ResponseOverviewNext RequestNext ResponseNot FoundPermanentRedirectRedirectRefreshRevalidatePathRevalidateTagUnauthorizedUnstable CacheUnstable NoStoreUnstable RethrowUpdateTagUse Link StatusUse ParamsUse PathnameUse Report Web VitalsUse RouterUse Search ParamsUse Selected Layout SegmentUse Selected Layout SegmentsUserAgent
EdgeTurbopackOverview
GlossaryOverview
Overview
Docs Hub

You can use the generateSitemaps function to generate multiple sitemaps for your application.

Returns

The generateSitemaps returns an array of objects with an id property.

URLs

Your generated sitemaps will be available at /.../sitemap/[id].xml. For example, /product/sitemap/1.xml.

Example

For example, to split a sitemap using generateSitemaps, return an array of objects with the sitemap id. Then, use the id to generate the unique sitemaps.

ts
filename="app/product/sitemap.ts" switcher

export async function generateSitemaps() {
  // Fetch the total number of products and calculate the number of sitemaps needed
  return [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }]
}

export default async function sitemap(props: {
  id: Promise<string>
}): Promise<MetadataRoute.Sitemap> {
  const id = await props.id
  // Google's limit is 50,000 URLs per sitemap
  const start = id * 50000
  const end = start + 50000
  const products = await getProducts(
    `SELECT id, date FROM products WHERE id BETWEEN ${start} AND ${end}`
  )
  return products.map((product) => ({
    url: `${BASE_URL}/product/${product.id}`,
    lastModified: product.date,
  }))
}
js
filename="app/product/sitemap.js" switcher

export async function generateSitemaps() {
  // Fetch the total number of products and calculate the number of sitemaps needed
  return [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }]
}

export default async function sitemap(props) {
  const id = await props.id
  // Google's limit is 50,000 URLs per sitemap
  const start = id * 50000
  const end = start + 50000
  const products = await getProducts(
    `SELECT id, date FROM products WHERE id BETWEEN ${start} AND ${end}`
  )
  return products.map((product) => ({
    url: `${BASE_URL}/product/${product.id}`,
    lastModified: product.date,
  }))
}

Version History

VersionChanges
v16.0.0The id values returned from generateSitemaps are now passed as a promise that resolves to a string to the sitemap function.
v15.0.0generateSitemaps now generates consistent URLs between development and production
v13.3.2generateSitemaps introduced. In development, you can view the generated sitemap on /.../sitemap.xml/[id]. For example, /product/sitemap.xml/1.