nextjs - 💡(How to fix) Fix App Router: root generateMetadata reruns a shared fetch on sibling navigation even when the shared layout UI is preserved [1 comments, 2 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#91409Fetched 2026-04-08 02:02:07
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

Root Cause

  • The shared layout UI is preserved across sibling navigation.
  • The root generateMetadata() still re-evaluates on navigation.
  • Because generateMetadata() calls the same shared fetch as the preserved layout, the shared fetch runs again and logs a new [shared-layout] fetch.
  • The client navigation request is an _rsc request and includes a refetch marker in next-router-state-tree.

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:59 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 22.21.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.26.2
Relevant Packages:
  next: 16.2.0-canary.99
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: N/A
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/Innei/nextjs-generate-metadata-shared-fetch-repro

To Reproduce

  1. Clone the reproduction repo.
  2. Run npm install.
  3. Run npm run build.
  4. Run npm run start.
  5. Open http://localhost:3000/alpha.
  6. Check the server logs and note the latest [shared-layout] fetch.
  7. Navigate to /beta using the in-app link.
  8. Check the server logs again.

Current vs. Expected behavior

Current behavior:

  • The shared layout UI is preserved across sibling navigation.
  • The root generateMetadata() still re-evaluates on navigation.
  • Because generateMetadata() calls the same shared fetch as the preserved layout, the shared fetch runs again and logs a new [shared-layout] fetch.
  • The client navigation request is an _rsc request and includes a refetch marker in next-router-state-tree.

Expected behavior:

  • If a shared layout segment is preserved across sibling navigation, root metadata that only depends on that preserved segment could be reused instead of triggering the shared fetch again.
  • If that reuse is intentionally not possible, the docs should state more explicitly that preserved layouts do not imply preserved metadata evaluation or preserved shared data reads.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:59 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 22.21.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.26.2
Relevant Packages:
  next: 16.2.0-canary.99
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected?

  • Linking and Navigating
  • Metadata

Which stage(s) are affected?

  • next dev (local)
  • next start (local)

Additional context

  • The repro intentionally uses headers() to keep the route dynamic.
  • getSharedLayoutData() is wrapped with react cache().
  • This shows that the repeated shared fetch is not a duplicate call within a single render pass; it happens across client navigations.
  • The repro is intended to be tested against next@canary, per the official bug report template guidance.
  • I searched the current issue list and did not find an exact duplicate for "root generateMetadata() reruns a preserved shared fetch on sibling route navigation"; the closest related item I saw was #62162, which is about clarifying React.cache() usage in generateMetadata().
  • If this is considered expected behavior, this report can be treated as an optimization or documentation request rather than a correctness bug.

extent analysis

TL;DR

The issue can be addressed by reusing the preserved layout segment's metadata or explicitly documenting that preserved layouts do not imply preserved metadata evaluation.

Guidance

  • Investigate the generateMetadata() function to determine why it re-evaluates on navigation, even when the shared layout is preserved.
  • Consider using React.cache() to memoize the result of generateMetadata() so that it is not re-run on subsequent navigations.
  • Review the getSharedLayoutData() function to ensure it is correctly utilizing the react cache() wrapper to prevent duplicate calls.
  • Verify that the headers() function is not causing the route to be re-evaluated unnecessarily.

Example

// Example of using React.cache() to memoize generateMetadata()
const cachedGenerateMetadata = React.cache(generateMetadata, {
  // Add dependencies that would cause the cache to be invalidated
});

Notes

The provided reproduction repository and environment information suggest that this issue is specific to the Next.js canary version. It is essential to test this against the canary version as per the official bug report template guidance.

Recommendation

Apply a workaround by reusing the preserved layout segment's metadata or explicitly documenting the current behavior, as the root cause of the issue is not entirely clear from the provided information. This approach will help mitigate the repeated shared fetch on sibling route navigation.

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