feat: render Server Component output with live params on soft navigation - #177
Draft
uhyo wants to merge 1 commit into
Draft
feat: render Server Component output with live params on soft navigation#177uhyo wants to merge 1 commit into
uhyo wants to merge 1 commit into
Conversation
Under file-system routing, a Server Component page or layout kept its build-time params (and output) after soft client-side navigation between pages of the same dynamic route, with the destination's pre-rendered payload unreachable in the build output (#174, remaining half). Server Component route nodes are now represented by a client slot (FsRouteSlot) in the route definitions instead of a baked element. The build pre-renders one RSC chunk per node per params combination through the existing defer registry (content-hashed, immutably cacheable), and bakes the params-to-chunk map into the slot. The slot reads the live params of the current match via the route object and renders the inline build-time output while they match the page's own params, or suspends on the destination's chunk after a soft navigation — inside the router's transition, so the old page stays visible until the new output is ready. A failed chunk resolution (a params combination that was never generated, or a fetch failure after a redeploy) falls back to a full page load, with a sessionStorage guard against reload loops. Since chunks are shared per params combination, this also stops each page's main payload from embedding every other page's rendered output, and Server Component layouts now receive only the params of segments at or above them (matching their per-combination pre-rendering) rather than the full page params. Closes #174 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ErSPPfkksH1SqMULJdivfG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the remaining half of #174: under file-system routing, a Server Component page or layout kept its build-time
params(and rendered output) after soft client-side navigation between pages of the same dynamic route. The destination's pre-rendered output existed in the build but was unreachable from the browser.Approach
Server Component route nodes are no longer baked into the route definitions as rendered elements. Instead, each is represented by a client slot (
FsRouteSlot), and navigation is handled by FUNSTACK Router in its entirety — no changes to the client entry, no navigation listeners.initial, so first load and hydration are unchanged (no extra fetch).useRouteParams(route). While they equal the payload's build params it rendersinitial; after a soft navigation it suspends on the destination's chunk inside the router's transition, so the old page stays visible until the new output is ready. Chunks are cached per URL, making back/forward instant.To keep
runtime.tsxunit-testable outside a Vite RSC environment, its impure edges (defer registry,virtual:funstack/config,#rsc-client) live in a newfs-routes/entries.tsxthat injects a small host object into the pure core. The publiccreateFsRoutesEntriesAPI is unchanged.Behavior changes
[lang]/layout sees{ lang }, not a descendant{ slug }), matching their per-combination pre-rendering and Next.js semantics. Previously they received the full page params.Testing
initialinlining, and stable route ids./ja → /ennow rendersenin the Server Component page), a new Server Component layout+page fixture under[lang]/info/, back/forward navigation, and no-JS-error sweeps.pnpm typecheck,pnpm lint,pnpm format:checkclean; docs site builds.Docs: the File-System Routing page's "known limitation" note is replaced with a description of how both component kinds stay live, the layout params rule, and the fallback behavior.
Closes #174
🤖 Generated with Claude Code
https://claude.ai/code/session_01ErSPPfkksH1SqMULJdivfG
Generated by Claude Code