SSR Overview
TanStack Router
File-based routingType-safe navigation
Vite SSR
Fast buildsHMR support
Direct API Call
No HTTP overheadFast response
TanStack Query
Automated HydrationCaching integration
Sonamu SSR Architecture
Sonamu implements SSR using TanStack Router + Vite.Core Components
web/src/TSX
entry-server.generated.tsx - Server rendering entry (auto-generated)TSX
entry-client.tsx - Client hydration entryTS
routeTree.gen.ts - TanStack Router route tree (auto-generated)routes/ - File-based routesTSX
__root.tsx - Root layoutTSX
index.tsx - / pathusers/TSX
$id.tsx - /users/:id pathentry-server.generated.tsx
Entry point for rendering React on the server (auto-generated):entry-client.tsx
Entry point for hydrating React on the client:TanStack Router Route Structure
Root Route
File Route
Dynamic Route
Vite Configuration
SSR vs CSR
Sonamu uses a hybrid approach:SSR Rendering (when data preloading)
- Fast First Contentful Paint
- SEO optimization
- Immediate display of initial data
CSR Rendering (default)
- Reduced server load
- Simple implementation
- Fast development
Development vs Production
Development Mode
dev all: API server integrates Vite to serve API + Web on a single port (HMR supported)dev api: Runs API only. Use when Web is not needed or when running Vite separatelydev web: Runs Vite dev server standalone. Pass Vite options after--