Resolve metadata independently across parallel routes (#97345)
## Motivation Parallel routes are separate rendering branches, but the existing metadata resolver collects every matched slot into one shared chain. As a result, traversal order can decide which slot supplies the document head, and metadata errors from one slot can interfere with another. ## What this does This adds a fork-aware resolver behind `experimental.parallelRouteMetadata` while retaining the existing resolver as the default. Each slot resolves metadata and viewport independently, with isolated accumulators, and a single branch is selected for the document head at every fork. The built-in selector prefers real routes over implicit fallbacks and prefers `children` when it contributes head data. Otherwise it chooses the branch with the deepest head definition, using route depth and lexical slot order only as stable tie-breakers. Head selection is separate from rendering outcomes. Every slot gets its own `MetadataOutlet`, which replays navigation and regular errors for that slot regardless of which branch supplied the head. ## Review notes - `generateMetadata`, `generateViewport`, and generated static metadata still start eagerly; a fork does not serialize sibling branches or parent/child generation. - Branch state is isolated only where the tree forks, preventing metadata mutation from crossing between slots. - An outlet rejects as soon as either metadata or viewport rejects, but resolves only after both succeed. This lets one failing result reach the slot boundary even if the other never settles. - Existing navigation convention metadata is preserved for the selected branch. Errors from unselected branches remain observable only through their own rendered outlets. - The old resolver remains available behind an explicit flag so this implementation can be compared or disabled during rollout. ## Verification - `pnpm --filter=next types` - Metadata resolver unit coverage - Parallel-route metadata, navigation, and not-found coverage in development and production with Turbopack and webpack <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment