nextjs - ✅(Solved) Fix Docs: Incorrect type for `id` in generateSitemaps example [1 pull requests, 3 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85691Fetched 2026-04-08 02:14:22
View on GitHub
Comments
3
Participants
4
Timeline
10
Reactions
3
Author
Timeline (top)
commented ×3closed ×1cross-referenced ×1issue_type_added ×1

Error Message

which causes a runtime or type error if followed exactly.

Fix Action

Fixed

PR fix notes

PR #85702: docs generate-sitemaps: fix async route param type and await example

Description (problem / solution / changelog)

What? This PR updates the generateSitemaps documentation to correctly reflect that route parameters in App Router functions can be asynchronous (Promise-wrapped) and should be awaited before use.

Why? In Next.js 15+, functions like generateSitemaps, generateMetadata, and generateStaticParams receive route parameters asynchronously. The existing example used a synchronous type (id: number), which can lead to confusion and potential runtime or TypeScript errors. This change ensures that the docs match the current framework behavior and provide a more accurate example for developers.

How?

Updated the TypeScript example to use id: Promise<number> and await id.

Updated the JavaScript example to await the parameter before using it.

Added a short note explaining that route params in App Router functions may be Promise-wrapped.

Verified formatting with pnpm prettier-fix.

Fixes: vercel/next.js#85691

Checklist (for contributors)

Ran pnpm prettier-fix before committing.

Followed the Docs Contribution Guide.

Linked the related issue using Fixes #85691.

No functional code changes; documentation only.

Changed files

  • docs/01-app/03-api-reference/04-functions/generate-sitemaps.mdx (modified, +16/-11)

Code Example

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

---

export default async function sitemap({ id }: { id: number })
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

Update the generateSitemaps example to use asynchronous destructuring for the id parameter, typed as Promise<number>.

Guidance

  • Verify the type of the id parameter in the generateSitemaps example is indeed incorrect by checking the Next.js 15+ documentation and comparing it with the current implementation.
  • Update the generateSitemaps example to use asynchronous destructuring, as shown in the provided code snippet, to fix the type error.
  • Ensure all route parameters in App Router functions are handled asynchronously, as they are wrapped in a Promise in Next.js 15+.
  • Review the documentation page (https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps) to confirm the update is reflected and accurate.

Example

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

Notes

This fix assumes the issue is solely related to the incorrect typing of the id parameter in the generateSitemaps example. If other parts of the code or documentation are affected, additional updates may be necessary.

Recommendation

Apply workaround: Update the generateSitemaps example to use asynchronous destructuring for the id parameter, as this directly addresses the identified issue with the incorrect type information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING