CSR, SSR, SSG, ISR and Streaming
Where and when HTML is produced, and how each strategy affects performance, SEO, cost and complexity.
Intermediate · about 3 hours · difficulty 3/5
Learn first: Client-Side Routing, Core Web Vitals and Performance Metrics, SEO and Metadata Basics
A plain Vite React app does client-side rendering (CSR): the server sends an almost empty HTML file and JavaScript builds the page in the browser. That is fine for dashboards behind a login, but it delays content, hurts SEO for public pages and depends entirely on the device's speed. Meta-frameworks let you choose, per route, where HTML is generated.
The strategies
- CSR: render in the browser. Simple hosting, rich interactivity, slower first content.
- SSR (server-side rendering): render HTML on each request, then hydrate it in the browser to attach event handlers. Fresh, personalised and SEO friendly, but needs a server and adds per-request cost.
- SSG (static site generation): render HTML at build time and serve it from a CDN. Fastest and cheapest, ideal for docs, blogs and marketing pages; content is only as fresh as the last build.
- ISR / revalidation: static pages that regenerate in the background after a time or on demand. Freshness without per-request rendering.
- Streaming SSR: send HTML in chunks as data resolves, using Suspense boundaries, so users see the shell immediately.
- Islands and partial hydration: ship static HTML and hydrate only interactive widgets (Astro's model). Server Components push the same idea further in React.
- Edge rendering: run SSR in data centres close to users.
Hydration pitfalls
Server and client must render the same markup. Using Date.now(), Math.random(), window or locale-dependent formatting during render causes hydration mismatch errors.
Choosing
Public, content-heavy pages favour SSG, ISR or SSR. Authenticated app screens can be CSR or SSR. Most real apps mix strategies per route.
Good enough to move on
Given a set of pages (landing, blog, product, dashboard), you can pick a strategy for each and justify it in terms of freshness, SEO, performance and cost.
Key concepts
- Client-side rendering
- Server-side rendering and hydration
- Static site generation
- Incremental static regeneration
- Streaming SSR
- Islands and partial hydration
- Edge rendering
- Hydration mismatches
Mini project
Write a one-page architecture note for an e-commerce site choosing a rendering strategy for home, category, product, cart, account and blog pages, with reasons and expected trade-offs.
Check yourself
Why does rendering the current time directly in a server-rendered component often cause a hydration warning?
Free resources
- Rendering on the Web (web.dev)
- Server rendering APIs (react.dev)