Files
Andrew ClarkandGitHub dcf649fd4d instant(): Only render shell, unless prefetch prop is set (#95150)
When using the instant() API, or the Navigation Inspector, the
prefetched state should match what a user is most likely to see in
production with a warm cache. So, when Partial Prefetching is enabled,
and the Link does not have a prefetch prop, only the shell should be
allowed to render.

Before this PR, the _entire_ prefetched state would display, regardless
of the prefetch configuration of the route and the link.

This is essential to prevent false negatives in tests that assert on the
prefetched state: the test must not depend on data that wouldn't be
prefetched in a real production environment.

As part of the fix, I also updated the logic to ignore any cache entries
that were already present before the `instant()` lock was acquired, to
ensure the test is not "polluted" by earlier prefetches or navigations.
Theoretically we could optimize this in the future but this is the
cleanest way to ensure this property for now.

<!-- NEXT_JS_LLM_PR -->
2026-06-25 03:54:01 +00:00

19 lines
577 B
TypeScript

import Link from 'next/link'
export default function HomePage() {
return (
<div>
<h1 data-testid="home-title">Partial Prefetch Shell Test</h1>
{/* Default (partial) prefetch — only the shell is prefetched. */}
<Link href="/dynamic-params/hello" id="partial-link">
Partial link
</Link>
{/* Full prefetch — a speculative (whole-route) prefetch that warms the
concrete-param entry too. */}
<Link href="/dynamic-params/hello" prefetch={true} id="full-link">
Full prefetch link
</Link>
</div>
)
}