nextjs - ✅(Solved) Fix Link prefetch in static export does not work when Link component has `prefetch={true}` [1 pull requests, 1 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#92341Fetched 2026-04-08 02:43:20
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
subscribed ×2issue_type_added ×1labeled ×1

Error Message

  • Clicking the link to page1 in this state results in no action, and no error messages are displayed in the console.

PR fix notes

PR #92917: fix <Link prefetch={true}> on output: "export"

Description (problem / solution / changelog)

What?

<Link prefetch={true}> on output: "export" fetches the html document instead of the per-segment __next.*.txt files, breaking both the prefetch-at-load and the subsequent click navigation.

Why?

a full prefetch issues a dynamic rsc request (request header + _rsc= cache-buster) against the bare route path. static hosts can't interpret the header and return the html document; the flight decode fails, the prefetch cache entry is rejected, and the click can't be served from it either.

How?

in export mode, getFetchStrategyFromPrefetchProp and the unstable_dynamicOnHover upgrade now return FetchStrategy.PPR. the ppr path already rewrites urls through addSegmentPathToUrlInOutputExportMode. gated on NODE_ENV === 'production' to match isOutputExportMode and keep next dev unchanged.

regression test under test/e2e/app-dir/static-export-link-prefetch-true/

fixes #92341

Changed files

  • packages/next/src/client/app-dir/link.tsx (modified, +12/-0)
  • packages/next/src/client/components/links.ts (modified, +9/-2)
  • test/e2e/app-dir/static-export-link-prefetch-true/app/layout.tsx (added, +11/-0)
  • test/e2e/app-dir/static-export-link-prefetch-true/app/page.tsx (added, +12/-0)
  • test/e2e/app-dir/static-export-link-prefetch-true/app/page1/page.tsx (added, +10/-0)
  • test/e2e/app-dir/static-export-link-prefetch-true/next.config.js (added, +8/-0)
  • test/e2e/app-dir/static-export-link-prefetch-true/server.mjs (added, +10/-0)
  • test/e2e/app-dir/static-export-link-prefetch-true/static-export-link-prefetch-true.test.ts (added, +86/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:01 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.28.1
Relevant Packages:
  next: 16.2.2 // Latest available version is detected (16.2.2).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: export
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/mdj-uk/static-export-prefetch-bug

To Reproduce

Current vs. Expected behavior

Current behavior:

  • When the page loads, it makes a GET request to http://localhost:3000/page1?_rsc=... which returns HTML instead of RSC payload.
  • Clicking the link to page1 in this state results in no action, and no error messages are displayed in the console.
<img width="500" alt="Image" src="https://github.com/user-attachments/assets/bff6cc1b-f654-4c49-99a6-dbd598e5e55d" />

Expected behavior:

  • Prefetch works and the Link function correctly as if the prefetch prop were not set or was set to "auto".
  • When prefetch="auto", it seems the correct behavior is that GET requests to __next._tree.txt, __next._head.txt, __next._index.txt, __next.page1.txt, __next.page1.__PAGE__.txt are made.
<img width="500" alt="Image" src="https://github.com/user-attachments/assets/38cd7230-c659-4a43-ad6f-b3bb153b1886" />
  • Alternatively, fetch /page1.txt which is also a RSC payload?

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:01 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.28.1
Relevant Packages:
  next: 16.2.2 // Latest available version is detected (16.2.2).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: export

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

Output

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

next build (local)

Additional context

  • Next.js 16.1.0 and later versions, including latest stable 16.2.2 and latest canary, has the behavior described in the issue.
  • Next.js 16.0.0 - 16.0.11 also fail to prefetch, fetching the HTML for /page1 during page load. However, clicking a link causes /page1.txt to be fetched again, and the link at least works.
  • In Next.js 15, it prefetches /page1.txt when page loads and the link works.

This issue was originally posted as #92213

extent analysis

TL;DR

  • The most likely fix is to modify the prefetch behavior in Next.js to correctly handle the fetching of RSC payloads.

Guidance

  • Review the prefetch prop configuration in the affected pages to ensure it is set to the expected value, such as "auto" or a custom function.
  • Verify that the getStaticProps and getStaticPaths functions are correctly implemented in the page components to handle the prefetching of RSC payloads.
  • Check the Next.js version and consider downgrading to version 15 if the issue is specific to versions 16.0.0 and later.
  • Inspect the network requests made during page load to confirm that the expected RSC payload requests are being made.

Example

  • No specific code snippet can be provided without more information about the page components and their configurations.

Notes

  • The issue seems to be specific to Next.js versions 16.0.0 and later, and the behavior differs between versions 16.0.0-16.0.11 and 16.1.0 and later.
  • The expected behavior is not clearly defined for all scenarios, and more information may be needed to provide a complete solution.

Recommendation

  • Apply workaround: Consider downgrading to Next.js version 15, which is reported to prefetch /page1.txt correctly, until a fix is available for the later versions.

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