Skip to content

Disable link prefetching site-wide - #5

Merged
kyleconroy merged 1 commit into
mainfrom
claude/head-requests-html-next-tree-n1nr5x
Sep 2, 2026
Merged

Disable link prefetching site-wide#5
kyleconroy merged 1 commit into
mainfrom
claude/head-requests-html-next-tree-n1nr5x

Conversation

@kyleconroy

Copy link
Copy Markdown
Contributor

Summary

A HAR capture of docs.sqlc.dev showed a HEAD request to every visible sidebar page followed by a GET for <page>/__next._tree.txt that 404s. Both come from Next 16's client router prefetching links in output: "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 .html route scheme forces scripts/fix-html-ext.mjs to move them into out-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 Link that RootProvider accepts as an override. components/provider.tsx now supplies a thin wrapper around next/link that forces prefetch={false}.

Verification

  • npm run types:check and npm run build pass.
  • Served the export locally and drove it with Playwright (load, scroll, hover, click):
Total requests HEAD / segment requests
Before 33 16
After 17 0
  • Clicking a sidebar link still navigates client-side via the full-page select.html.txt payload, exactly as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rb8SXvBwzUXaUEQtYHrD9V


Generated by Claude Code

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
@kyleconroy
kyleconroy merged commit 980340b into main Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant