Files
Zack TannerandGitHub ae3f9f5187 partial fallbacks: complete generic shells into more specific shells (#91231)
In #91158, I wired up the plumbing to indicate whether a partial
fallback shell is upgradeable. The previous heuristic was too coarse.
This wires up the handling in `next start`.

This PR teaches the runtime to complete a fallback shell only as far as
prerendering allows. Instead of promoting a generic shell like
`/[one]/[two]` directly to `/c/foo`, it promotes it to the most specific
prerendered shell for that branch, `/c/[two]`, where `[one]` has
`generateStaticParams`. That means later requests can reuse the more
complete shell, while fully dynamic params continue to stream as dynamic
content.

With this change:

- the first request still serves the generic fallback shell immediately
- the background revalidate writes a more specific shell, not a fully
concrete route
- later requests for the same prerendered branch reuse that shell
- upgrading stops once only fully dynamic params remain

This keeps the runtime behavior aligned with the build-time
`remainingPrerenderableParams` contract from the downstack PR.
2026-03-13 18:21:20 -07:00

42 lines
763 B
TypeScript

import { Suspense, type ReactNode } from 'react'
export function generateStaticParams() {
return [{ lang: 'en' }]
}
type LayoutProps = {
children: ReactNode
params: Promise<{ lang: string }>
}
async function LayoutImpl({ children, params }: LayoutProps) {
const { lang } = await params
return (
<html>
<body>
<div id="lang">{lang}</div>
{children}
</body>
</html>
)
}
export default async function LayoutWrapper(props: LayoutProps) {
return (
<Suspense
fallback={
<html>
<body>
<div id="lang-fallback" data-fallback>
loading lang...
</div>
</body>
</html>
}
>
<LayoutImpl {...props} />
</Suspense>
)
}