Render router layouts during SSR - #74
Conversation
The SSR router only resolved the leaf component for a route — layouts declared via `layout:` on route groups were dropped, and the leaf was mounted directly into the RouterView host div. Layout components like AppShell and DashboardLayout only appeared after hydration, producing a tree mismatch that forced the client to re-render the RouterView's subtree on load. Walk route groups in createServerRouter to collect a layout chain (outermost → innermost) and capture queryModes metadata; resolve mode-query children by their query-string param instead of by path segment. createSSRRouterState.getComponentAtDepth now mirrors the client Router contract: layouts at depth < layoutCount (with page/route/params plus activeKey/keys/navigate for query-mode depths), leaf at depth === layoutCount. Expose `layout` and `mode` on the SSR RouteGroup type so the route shape the router actually supports type-checks; the legacy `component` field stays as a deprecated alias. Fix a broken vite-plugin-gea import in the ssr/router-v2 example so its dev server starts.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR adds SSR support for router layout chains. ChangesSSR Router Layout Chain
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
New Features
Bug Fixes
Tests