next.js
cce7bf2f - Retain interception route host slots (#97242)

Commit
2 days ago
Retain interception route host slots (#97242) ## Summary Interception routes represent a partial update to the layout that hosts them. Today we model this for `children` by synthesizing a `__DEFAULT__` route backed by `default-null`, but named siblings still use normal default matching even though they should retain their active state too. This makes retention relative to the interception host instead of the `children` key. Every non-intercepting sibling gets the existing `__DEFAULT__` marker backed by `default-null`, while slots inside the newly selected interception subtree continue to use normal matching and real defaults. The coverage uses a named-only host to verify that named siblings retain client state without evaluating a user default, that a sibling without a default also retains, and that a hard refresh still loads the canonical route. ## Example Consider this route tree: ```text app/ ├── named-host/ │ ├── layout.tsx # renders canonical, content, secondary, and modal │ ├── @canonical/ │ │ └── page.tsx │ ├── @content/ │ │ ├── page.tsx # renders a stateful counter │ │ └── default.tsx # throws if evaluated │ ├── @secondary/ │ │ └── page.tsx # has no default.tsx │ └── @modal/ │ ├── default.tsx │ └── (..)named-target/ │ └── page.tsx # intercepted target └── named-target/ └── page.tsx # canonical route ``` Before this change, a soft navigation from `/named-host` to `/named-target` could replace `@content` with its throwing default and treat `@secondary` as missing because only `children` had retain semantics. After this change, only `@modal` switches to the intercepted page; `@content` and `@secondary` keep their existing UI and the counter keeps its state. A hard refresh still renders the canonical `/named-target` route instead of the interception host. ## Verification - Turbopack and webpack production coverage in `interception-dynamic-segment` - The same production coverage with Cache Components enabled <!-- NEXT_JS_LLM -->
Author
Parents
Loading