Skip to content

Commit 980340b

Browse files
kyleconroyclaude
andauthored
Disable link prefetching site-wide (#5)
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. Claude-Session: https://claude.ai/code/session_01Rb8SXvBwzUXaUEQtYHrD9V Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 7178b6e commit 980340b

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

components/provider.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
'use client';
22
import SearchDialog from '@/components/search';
33
import { RootProvider } from 'fumadocs-ui/provider/next';
4-
import { type ReactNode } from 'react';
4+
import NextLink from 'next/link';
5+
import { type ComponentProps, type ReactNode } from 'react';
6+
7+
// Every Fumadocs link (sidebar, page body, breadcrumb, prev/next footer)
8+
// renders through the framework Link supplied here. Prefetching is disabled
9+
// site-wide: this is a static export whose .html routes can't ship Next's
10+
// per-segment payloads (see scripts/fix-html-ext.mjs), so each prefetch would
11+
// only cost a HEAD to the page plus a 404 for its __next._tree.txt.
12+
function Link({ href = '#', ...props }: ComponentProps<'a'> & { prefetch?: boolean }) {
13+
return <NextLink {...props} href={href} prefetch={false} />;
14+
}
515

616
export function Provider({ children }: { children: ReactNode }) {
7-
return <RootProvider search={{ SearchDialog }}>{children}</RootProvider>;
17+
return (
18+
<RootProvider search={{ SearchDialog }} components={{ Link }}>
19+
{children}
20+
</RootProvider>
21+
);
822
}

0 commit comments

Comments
 (0)