mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
badf4b6c17
### What? This PR introduces comprehensive type-aware parameter tracking and fallback handling for dynamic routes in PPR scenarios, with enhanced client-side parameter resolution capabilities. ### Why? When using client segment cache with dynamic routes, Next.js faced several critical issues that prevented reliable client-side navigation: **1. Parameter Resolution Inconsistencies**: The previous system had inconsistent behavior when handling parallel route parameters, causing unpredictable parameter resolution across different route segments. This led to client-side navigation failures when encountering dynamic route segments that weren't statically generated. **2. Limited Parameter Type Awareness**: The routing system lacked semantic understanding of different parameter types (dynamic, catchall, optional catchall), making it impossible to implement advanced parameter handling features or provide proper fallback behavior for different parameter scenarios. **3. Incomplete Fallback Parameter Collection**: The original `getFallbackRouteParams()` used simple string-based tracking that couldn't capture the full complexity of parameter relationships, especially in parallel route scenarios where parameters might be defined at different levels of the route tree. **4. Client-Side Parameter Extraction Gaps**: The `getDynamicParam` function had limitations in handling fallback route parameters and lacked proper encoding/decoding mechanisms, leading to potential client-side errors during route resolution. **5. Configuration Validation Missing**: There was no validation to ensure `clientParamParsing` was only enabled when `clientSegmentCache` was also enabled, leading to potential misconfigurations in production. These issues became critical blockers for implementing reliable client-side parameter parsing in PPR scenarios, particularly for the Vercel platform integration (https://github.com/vercel/vercel/pull/13740). ### How? - Introduces `DynamicParamTypes` and `OpaqueFallbackRouteParams` for structured, type-aware parameter tracking - Refactors `getFallbackRouteParams()` to use route modules for comprehensive parameter collection across the routing tree - Adds `resolveParallelRouteParams` function to eliminate parallel route parameter inconsistencies - Enhances `getDynamicParam` with proper fallback parameter handling, encoding, and comprehensive catchall support - Implements configuration validation in `assignDefaultsAndValidate()` to prevent misconfigurations - Adds clientParamParsing boolean to the routes manifest configuration (needed for https://github.com/vercel/vercel/pull/13740) - Updates build pipeline to properly handle enhanced fallback parameters across static generation, export, and rendering phases NAR-305 --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
23 lines
383 B
TypeScript
23 lines
383 B
TypeScript
import React, { Suspense } from 'react'
|
|
|
|
export default function Root({
|
|
children,
|
|
slot,
|
|
}: {
|
|
children: React.ReactNode
|
|
slot: React.ReactNode
|
|
}) {
|
|
return (
|
|
<html>
|
|
<body>
|
|
<Suspense>
|
|
<div id="slot">{slot}</div>
|
|
</Suspense>
|
|
<Suspense>
|
|
<div id="children">{children}</div>
|
|
</Suspense>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|