Skip to content

Server render the nearest not-found boundary - #98583

Open
AdzerKI wants to merge 1 commit into
vercel:canaryfrom
AdzerKI:not-found-server-render
Open

Server render the nearest not-found boundary#98583
AdzerKI wants to merge 1 commit into
vercel:canaryfrom
AdzerKI:not-found-server-render

Conversation

@AdzerKI

@AdzerKI AdzerKI commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #62228.

notFound() answers with the empty error shell. React's streaming SSR does not run client error boundaries, so HTTPAccessFallbackBoundary never produces markup on the server: the not-found page and the layouts around it are drawn by the client only. Crawlers and the first frame get an empty body, and a blocking script in the root layout never runs.

The error payload now builds the nearest not-found boundary inside its layouts with createFullComponentTree — the subtree builder of a matched path — and keeps the shell when the route declares no boundary or the build fails. global-not-found keeps its own tree.

Server HTML now matches what the client renders: the root boundary for a root-level notFound(), the nested one for a nested route. Covered by a new assertion in not-found/basic on the fetched markup; the 16 not-found and global-not-found e2e suites pass.

notFound() answers with the empty error shell: React's streaming SSR does not
run client error boundaries, so the not-found markup and the layouts around it
are drawn by the client only. Crawlers and the first frame get an empty body,
and a blocking script in the root layout never runs.

The error payload now builds the nearest not-found boundary inside its layouts
with the same subtree builder as a matched path, and falls back to the shell
when the route declares none or the build fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

404 page isn't server rendered when using notFound()

1 participant