Skip to content

Docs: Incorrect type for id in generateSitemaps example #85691

@dohun0310

Description

@dohun0310

What is the documentation issue?

There is incorrect type information in the generateSitemaps example.

The id parameter in the example is typed as a synchronous number, but in Next.js 15+ it should be accessed asynchronously as Promise<{ id: number }> (same as other dynamic route parameters such as generateMetadata or generateStaticParams).

Is there any context that might help us understand?

In Next.js 15, route parameters in App Router functions like generateMetadata, generateStaticParams, and sitemap are wrapped in a Promise.

Therefore, the generateSitemaps example should show asynchronous destructuring, e.g.:

export default async function sitemap({
  id
}: {
  id: Promise<number>
}): Promise<MetadataRoute.Sitemap>{
  const index = await id;
  // ...
}

Currently, the docs use:

export default async function sitemap({ id }: { id: number })

which causes a runtime or type error if followed exactly.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions