nextjs - ✅(Solved) Fix Value returned from `generateSitemaps` is received as a string instead of number [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#86959Fetched 2026-04-08 02:08:14
View on GitHub
Comments
3
Participants
4
Timeline
12
Reactions
0
Author
Timeline (top)
commented ×3referenced ×3labeled ×2closed ×1

Root Cause

This means that, for example, doing a switch case over the id does not work, because it never matches the number in the switch case. See reproduction repo for minimal repro

Fix Action

Fixed

PR fix notes

PR #86984: docs: fix generateSitemaps returned type signature

Description (problem / solution / changelog)

Closes: https://github.com/vercel/next.js/issues/86959

Changed files

  • docs/01-app/02-guides/upgrading/version-16.mdx (modified, +2/-2)
  • docs/01-app/03-api-reference/03-file-conventions/01-metadata/sitemap.mdx (modified, +2/-2)
  • docs/01-app/03-api-reference/04-functions/generate-sitemaps.mdx (modified, +2/-2)

Code Example

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 8937
  Available CPU cores: 16
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.0.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/therungg/next-sitemap-generation-typing-bug

To Reproduce

  1. Create a sitemap as per the docs https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps#example
  2. await the id in the sitemap function
  3. The id is actually a string, not a number

Current vs. Expected behavior

The id received in the sitemap function is actually a string, not a number as the type indicates. I expect it to be a number.

This means that, for example, doing a switch case over the id does not work, because it never matches the number in the switch case. See reproduction repo for minimal repro

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 8937
  Available CPU cores: 16
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.0.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

No response

extent analysis

TL;DR

Update the type definition for the id in the sitemap function to reflect it as a string instead of a number.

Guidance

  • Verify the type of the id received in the sitemap function using console.log(typeof id) to confirm it's a string.
  • Update any switch case statements or other code that relies on the id being a number to handle it as a string instead.
  • Check the Next.js documentation for any updates or guidance on the expected type of the id in the sitemap function.
  • Consider opening an issue with Next.js to report the type discrepancy and suggest an update to their documentation or type definitions.

Example

// Before
switch (id) {
  case 1:
    // code
    break;
}

// After
switch (id) {
  case '1':
    // code
    break;
}

Notes

The fix assumes that the id will always be a string representation of a number. If the id can be a non-numeric string, additional error handling may be necessary.

Recommendation

Apply workaround: update the code to handle the id as a string, as the current type definition appears to be incorrect. This will allow the code to function as expected until the type definition can be updated.

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

nextjs - ✅(Solved) Fix Value returned from `generateSitemaps` is received as a string instead of number [1 pull requests, 3 comments, 4 participants]