Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Nov 25, 2025

fixes #5956

Summary by CodeRabbit

  • New Features

    • Route match objects now include SSR metadata, improving visibility of per-route SSR settings.
    • Client hydration now synchronizes and restores per-route SSR settings during app initialization.
  • Bug Fixes

    • Removed client-side runtime guards that previously errored when SSR options were present, preventing unexpected client-side failures.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Walkthrough

Adds a public ssr field to route match records produced by RouterCore and propagates per-match SSR settings into route options during client-side hydration; removes several client-side runtime guards that previously errored if Route.options.ssr existed.

Changes

Cohort / File(s) Summary
Core match metadata
packages/router-core/src/router.ts
Adds a new public ssr property to match objects created in RouterCore.matchRoutesInternal (value is route.options.ssr on client, undefined on server).
SSR hydration sync
packages/router-core/src/ssr/ssr-client.ts
Adds setRouteSsr(match) helper and calls it during hydration (when dehydrated match missing and after hydrateMatch) to apply match.ssr to route.options.ssr.
E2E: selective-ssr route guards removed
e2e/react-start/selective-ssr/src/routes/__root.tsx, e2e/react-start/selective-ssr/src/routes/posts.$postId.tsx, e2e/react-start/selective-ssr/src/routes/posts.tsx, e2e/solid-start/selective-ssr/src/routes/__root.tsx, e2e/solid-start/selective-ssr/src/routes/posts.$postId.tsx, e2e/solid-start/selective-ssr/src/routes/posts.tsx
Removes client-side runtime assertions that threw errors when Route.options.ssr existed on the client; retains existing logging and other logic.

Sequence Diagram(s)

sequenceDiagram
  %% Styling note: green = client-side, blue = router core, gray = server/hydration data
  participant Browser as Browser (client)
  participant RouterCore as RouterCore
  participant SSRClient as ssr-client
  participant Dehydrated as DehydratedState

  Note over Browser,RouterCore: Navigation / Hydration start
  Browser->>RouterCore: matchRoutesInternal(request)
  RouterCore-->>RouterCore: create match { id, ssr: isServer ? undefined : route.options.ssr, ... }
  RouterCore->>Browser: return matches

  alt Hydration with dehydrated state
    Browser->>Dehydrated: read dehydrated match
    Dehydrated-->>SSRClient: provide dehydratedMatch
    SSRClient->>RouterCore: hydrateMatch(match, dehydratedMatch)
    SSRClient->>RouterCore: setRouteSsr(match)  %% apply match.ssr -> route.options.ssr
  else No dehydrated match found
    SSRClient->>RouterCore: setRouteSsr(match)  %% still apply match.ssr -> route.options.ssr
  end

  Note over Browser,RouterCore: Route.options.ssr now aligned with match.ssr on client
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Heterogeneous changes across core SSR logic and multiple E2E route files.
  • Areas needing attention:
    • Consumers of match objects should be checked for the new ssr field and server/client shape differences.
    • Hydration spots where setRouteSsr is invoked to ensure no missed edge cases.
    • Removed client-side guards in E2E routes — verify tests and runtime behavior for regressions (remounting issues referenced in linked issue).

Possibly related PRs

Suggested reviewers

  • nlynzaad

Poem

🐰 A matching hop, a tiny SSR tune,

On client it sings, on server it's noon,
Hydration nudges options in place,
No more brave guards to race or to chase,
Routes snug together — a warm rabbit embrace 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely identifies the main fix: preventing remounting when ssr:false is set, which directly addresses the linked issue #5956.
Linked Issues check ✅ Passed Changes add ssr field to match objects and propagate it to route options during hydration, while removing client-side checks that enforce deletion of ssr options, effectively fixing the remounting issue described in #5956.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the ssr:false remounting issue: core router logic handles ssr metadata, SSR client logic propagates it during hydration, and test files remove obsolete client-side guards.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-5956

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 566022f and fba306f.

📒 Files selected for processing (6)
  • e2e/react-start/selective-ssr/src/routes/__root.tsx (0 hunks)
  • e2e/react-start/selective-ssr/src/routes/posts.$postId.tsx (0 hunks)
  • e2e/react-start/selective-ssr/src/routes/posts.tsx (0 hunks)
  • e2e/solid-start/selective-ssr/src/routes/__root.tsx (0 hunks)
  • e2e/solid-start/selective-ssr/src/routes/posts.$postId.tsx (0 hunks)
  • e2e/solid-start/selective-ssr/src/routes/posts.tsx (0 hunks)
💤 Files with no reviewable changes (6)
  • e2e/react-start/selective-ssr/src/routes/posts.tsx
  • e2e/react-start/selective-ssr/src/routes/posts.$postId.tsx
  • e2e/solid-start/selective-ssr/src/routes/posts.$postId.tsx
  • e2e/solid-start/selective-ssr/src/routes/posts.tsx
  • e2e/react-start/selective-ssr/src/routes/__root.tsx
  • e2e/solid-start/selective-ssr/src/routes/__root.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Nov 25, 2025

View your CI Pipeline Execution ↗ for commit fba306f

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 1m 19s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-25 20:04:03 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 25, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5964

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5964

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5964

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5964

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5964

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5964

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5964

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5964

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5964

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5964

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5964

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5964

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5964

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5964

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5964

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5964

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5964

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5964

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5964

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5964

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5964

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5964

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5964

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5964

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5964

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5964

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5964

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5964

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5964

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5964

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5964

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5964

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5964

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5964

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5964

commit: fba306f

@schiller-manuel schiller-manuel merged commit 369a09b into main Nov 25, 2025
6 checks passed
@schiller-manuel schiller-manuel deleted the fix-5956 branch November 25, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start: Updating search params when ssr: false causes page to unmount and remount

2 participants