Feature Request: Support Async Route Params in Nested sitemap.ts Files #85994
Unanswered
bennajah
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, sitemap.ts files in the app directory cannot access or resolve dynamic route parameters, especially in nested or localized routes.
For example, when using a folder structure like this:
app/
[locale]/
sitemap.ts
page.tsx
There’s no way to access the [locale] param inside app/[locale]/sitemap.ts.
This prevents developers from generating localized sitemaps for multilingual or multi-region setups.
💡 Proposed Solution
Allow sitemap.ts to accept and resolve async route params, similar to how generateMetadata and generateStaticParams work.
Example:
Then, the root sitemap could reference all localized sitemaps:
✅ Benefits
Enables localized SEO by generating per-locale sitemaps.
Keeps sitemap logic consistent with other async functions like generateMetadata.
Reduces duplication and improves maintainability in internationalized projects.
🧠 Use Case Example
International websites ([locale]/page.tsx) need locale-specific URLs and metadata.
Each locale should have its own sitemap for better indexing by search engines.
Root sitemap.ts should list all localized sitemaps.
Beta Was this translation helpful? Give feedback.
All reactions