Disable link prefetching site-wide - #5
Merged
Conversation
Next's client router prefetches every visible link. In output: "export"
mode that means a HEAD request to the page followed by a GET for its
__next._tree.txt segment payload. Those payloads are not deployed (the
.html route scheme forces scripts/fix-html-ext.mjs to move them aside),
so every prefetch was two wasted requests, the second a 404.
Every Fumadocs link renders through the framework Link from RootProvider,
so supply one that forces prefetch={false}. Navigation still works: a
click falls back to the full-page .txt payload as before.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rb8SXvBwzUXaUEQtYHrD9V
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A HAR capture of docs.sqlc.dev showed a
HEADrequest to every visible sidebar page followed by aGETfor<page>/__next._tree.txtthat 404s. Both come from Next 16's client router prefetching links inoutput: "export"mode: it sends a HEAD to check the page is reachable, then asks for the per-segment route tree at a URL under the page path.Those segment payloads are never deployed. The
.htmlroute scheme forcesscripts/fix-html-ext.mjsto move them intoout-segments/, which GitHub Pages does not serve. So every prefetch was two wasted requests, the second a 404.Change
Next has no global switch for Link prefetching, but every Fumadocs link (sidebar, page body, breadcrumb, prev/next footer) renders through the framework
LinkthatRootProvideraccepts as an override.components/provider.tsxnow supplies a thin wrapper aroundnext/linkthat forcesprefetch={false}.Verification
npm run types:checkandnpm run buildpass.select.html.txtpayload, exactly as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rb8SXvBwzUXaUEQtYHrD9V
Generated by Claude Code