Files
Josh StoryandGitHub 1931877c29 Remove prefetch from instant config (#92761)
prefetching is now controlled with the prefetch export and this option
is inert on the instant export. this removes the prefetch option as a
valid property on the instant config type.

also updates the ts plugin for this export and adds the definition for
the previously landed prefetch export
2026-04-17 10:44:45 -07:00

37 lines
1.1 KiB
TypeScript

import { ReactNode, Suspense } from 'react'
import { cookies } from 'next/headers'
// This layout uses runtime prefetching and sits ABOVE the [item] param.
// It's shared between /test-independent-head/a and /test-independent-head/b.
// Once cached from the first prefetch, a subsequent prefetch to a sibling
// page won't need a runtime request for this layout — it's already cached.
export const unstable_instant = {
samples: [
{
cookies: [{ name: 'theme', value: 'default' }],
searchParams: { q: null },
params: { item: 'a' },
},
],
}
export const unstable_prefetch = 'force-runtime'
async function LayoutContent({ children }: { children: ReactNode }) {
const cookieStore = await cookies()
const theme = cookieStore.get('theme')?.value ?? 'default'
return (
<div>
<p id="layout-independent-head">Shared layout (theme: {theme})</p>
{children}
</div>
)
}
export default function Layout({ children }: { children: ReactNode }) {
return (
<Suspense fallback={<p>Loading layout...</p>}>
<LayoutContent>{children}</LayoutContent>
</Suspense>
)
}