Files
next.js/test/e2e/app-dir/prefetch-true-instant/app/layout-instant/page.tsx
Andrew ClarkandGitHub 5aa4568bf9 Ignore prefetch={true} on Links to routes with instant (#90061)
When a route has `unstable_instant` defined on any segment, setting
`prefetch={true}` on a Link to that route is now a no-op. The prefetch
behaves the same as the default auto strategy — cached content is
prefetched but dynamic content is deferred to navigation time.

A full static prefetch doesn't make sense for routes with instant
configs, since those segments use runtime prefetching. Rather than
silently doing something the developer didn't intend, we ignore the prop
entirely.

To detect this on the client, the server now sends a bitmask instead of
a boolean for the per-segment prefetch metadata. One bit tracks whether
the subtree contains any instant config, which propagates up so the
client can check it at the root without traversing.
2026-02-16 18:35:51 -05:00

35 lines
863 B
TypeScript

import { Suspense } from 'react'
import { cookies } from 'next/headers'
import { connection } from 'next/server'
// No instant config on the page — only the layout has it.
export default async function Page() {
return (
<main>
<Suspense fallback={<div>Loading cached...</div>}>
<CachedWrapper />
</Suspense>
<Suspense fallback={<div>Loading dynamic...</div>}>
<Dynamic />
</Suspense>
</main>
)
}
async function CachedWrapper() {
const cookieStore = await cookies()
const value = cookieStore.get('test')?.value ?? 'default'
return <Cached value={value} />
}
async function Cached({ value }: { value: string }) {
'use cache'
return <div id="cached-content">Cached content: {value}</div>
}
async function Dynamic() {
await connection()
return <div id="dynamic-content">Dynamic content</div>
}