nextjs - 💡(How to fix) Fix App Router: dynamic route params not available in generateMetadata when page is statically rendered [6 comments, 3 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#92888Fetched 2026-04-17 08:25:42
View on GitHub
Comments
6
Participants
3
Timeline
13
Reactions
0
Author
Timeline (top)
commented ×6labeled ×2subscribed ×2closed ×1

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11
Binaries:
  Node: 20.11.0
  npm: 10.2.4
Relevant Packages:
  next: 15.0.0
  react: 19.0.0
  typescript: 5.4.0
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template

To Reproduce

  1. Create a dynamic route e.g. /app/[slug]/page.tsx
  2. Add a generateMetadata function that uses params.slug
  3. Run next build with static export
  4. Observe that params is undefined inside generateMetadata

Current vs. Expected behavior

Current behavior: params is undefined inside generateMetadata during static build when using App Router dynamic routes. This causes the metadata to be generated with missing or incorrect values.

Expected behavior: params should contain the dynamic route values (e.g. { slug: 'my-post' }) inside generateMetadata, matching the same params passed to the page component itself.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11
Binaries:
  Node: 20.11.0
  npm: 10.2.4
Relevant Packages:
  next: 15.0.0
  react: 19.0.0
  typescript: 5.4.0

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

Dynamic Routes

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

next build (local)

Additional context

No response

extent analysis

TL;DR

  • Modify the generateMetadata function to correctly handle dynamic route parameters during static build.

Guidance

  • Review the generateMetadata function implementation to ensure it properly accounts for the dynamic route parameters, potentially by using a different approach to access the params object.
  • Verify that the params object is correctly passed to the page component and investigate why it's not available within generateMetadata.
  • Check the Next.js documentation for any specific guidelines or recommendations on using dynamic route parameters with generateMetadata during static build.
  • Consider testing the generateMetadata function with a static route to isolate if the issue is specific to dynamic routes.

Example

  • No explicit code example can be provided without modifying the original code, but reviewing the generateMetadata function in the provided codesandbox example may help identify the issue.

Notes

  • The provided environment information and package versions may be relevant to the issue, but without further details, it's unclear if upgrading or downgrading any packages would resolve the issue.
  • This solution assumes that the issue is specific to the generateMetadata function and dynamic routes, and may not apply to other use cases.

Recommendation

  • Apply workaround: Modify the generateMetadata function to correctly handle dynamic route parameters, as the root cause appears to be related to how the function accesses the params object during static build.

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