Skip to content

renderHTTPAccessFallbackPage does not pass params to layout components #346

@Jbithell

Description

@Jbithell

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

  1. Create a Next.js app with a dynamic [lang] route segment
  2. 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...
}
  1. Navigate to any URL that triggers a 404 (e.g. /en/nonexistent-page)
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions