renderHTTPAccessFallbackPage does not pass params to layout components
When vinext renders HTTP access fallback pages (404, 403, 401), layout components are rendered without the params prop, causing layouts that destructure route params to crash with:
Cannot destructure property 'lang' of '(intermediate value)' as it is undefined.
Root cause
In the bundled output, renderHTTPAccessFallbackPage creates layout elements with only { children } and no params:
// renderHTTPAccessFallbackPage path — no params passed
const LayoutComponent = layouts[i3]?.default;
if (LayoutComponent) {
element = createElement(LayoutComponent, { children: element });
}
The normal render path correctly passes params:
// normal render path — params passed correctly
const layoutProps = { children: element, params: makeThenableParams(params) };
This affects both the RSC and non-RSC branches within renderHTTPAccessFallbackPage.
Reproduction
- Create a Next.js app with a dynamic
[lang] route segment
- In
app/[lang]/layout.tsx, destructure lang from params:
export default async function RootLayout({
params,
children,
}: {
params: Promise<{ lang: string }>;
children: React.ReactNode;
}) {
const { lang } = await params;
// use lang...
}
- Navigate to any URL that triggers a 404 (e.g.
/en/nonexistent-page)
- The layout crashes because
params is undefined
Expected behavior
renderHTTPAccessFallbackPage should pass params: makeThenableParams(params) to layout components, matching the normal render path.
Workaround
Add nullish coalescing when destructuring params in layouts:
const { lang } = (await params) ?? {};
Environment
- vinext:
^0.0.22
- next:
15.5.2
renderHTTPAccessFallbackPagedoes not passparamsto layout componentsWhen vinext renders HTTP access fallback pages (404, 403, 401), layout components are rendered without the
paramsprop, causing layouts that destructure route params to crash with:Root cause
In the bundled output,
renderHTTPAccessFallbackPagecreates layout elements with only{ children }and noparams:The normal render path correctly passes params:
This affects both the RSC and non-RSC branches within
renderHTTPAccessFallbackPage.Reproduction
[lang]route segmentapp/[lang]/layout.tsx, destructurelangfromparams:/en/nonexistent-page)paramsisundefinedExpected behavior
renderHTTPAccessFallbackPageshould passparams: makeThenableParams(params)to layout components, matching the normal render path.Workaround
Add nullish coalescing when destructuring params in layouts:
Environment
^0.0.2215.5.2