mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
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.
42 lines
763 B
TypeScript
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>
|
|
)
|
|
}
|