Files
Andrew ClarkandGitHub c39c7179a4 Suppress prefetch={true} warning when route opts out via instant = false (#95099)
In dev with Cache Components, navigating via a `<Link prefetch={true}>`
to a route that hasn't opted into Partial Prefetching logs a warning,
since the full prefetch pulls in dynamic data and defeats the
static/dynamic split.

`instant = false` is the explicit API for opting a route out of this
validation, so it should silence the warning. Previously it didn't: an
`instant = false` segment set no prefetch hint at all, so the warning
still fired.

Add a `SubtreeHasInstantFalse` PrefetchHint, set on any segment that
exports `instant = false` and propagated up to the root (mirroring
`SubtreeHasPartialPrefetching`). The dev warning now skips routes where
this bit is present anywhere on the target subtree.

This is warning-only and kept separate from the existing
`PrefetchDisabled` bit, which feeds `StaticPrefetchDisabled` and would
change actual prefetch behavior.
2026-06-24 17:52:22 -04:00

44 lines
1.5 KiB
TypeScript

import { LinkAccordion } from '../components/link-accordion'
export default function Page() {
return (
<main>
<h1>Home</h1>
<ul>
<li>
{/* prefetch={true} + no partial prefetching opt-in => should warn */}
<LinkAccordion href="/default-route" prefetch={true}>
/default-route
</LinkAccordion>
</li>
<li>
{/* prefetch={true} but the route opts into partial prefetching =>
should NOT warn */}
<LinkAccordion href="/partial-route" prefetch={true}>
/partial-route
</LinkAccordion>
</li>
<li>
{/* default prefetch (not a "full" prefetch) => should NOT warn,
even though the route has no partial prefetching opt-in */}
<LinkAccordion href="/control-route">/control-route</LinkAccordion>
</li>
<li>
{/* prefetch={true} but the page exports `instant = false`, the
explicit opt-out => should NOT warn */}
<LinkAccordion href="/instant-false-route" prefetch={true}>
/instant-false-route
</LinkAccordion>
</li>
<li>
{/* prefetch={true} and `instant = false` is on a parent layout (not
the page) => should NOT warn (the hint propagates up) */}
<LinkAccordion href="/instant-false-layout" prefetch={true}>
/instant-false-layout
</LinkAccordion>
</li>
</ul>
</main>
)
}