Programming
We provide developers and engineers the guides and tutorials they...
Search
We provide developers and engineers the guides and tutorials they...
Content is king. It's not just about how you're going to write, b...
Looking for an engaging connection with thousands of other people...
SSR vs CSR vs static generation compared: how each works, effects on speed and SEO, hydration, streaming and server components, and how to choose.
Quick answer: The difference is where the HTML is built. With client-side rendering (CSR), the server sends a nearly empty page plus a JavaScript bundle, and the browser builds the interface. With server-side rendering (SSR), the server builds the full HTML for each request and sends it ready to display. With static site generation (SSG), the HTML is built once in advance and served as files. SSR and SSG show content sooner and are easier for search engines. CSR is simpler to host and gives fluid, app-like navigation once loaded. Modern frameworks mix these per page, and the right choice depends on how dynamic and how public each page is.
The server's response is minimal:
<!doctype html>
<html>
<head><title>App</title></head>
<body>
<div id="root"></div>
<script src=/bundle.js></script>
</body>
</html>
Then:
This is a classic single-page application (SPA). After the first load, navigation happens in the browser without full page reloads.
Strengths
Weaknesses
Strengths
Weaknesses
Server-rendered HTML is static. Buttons do nothing until JavaScript attaches event handlers. Hydration is that process: the framework loads in the browser, runs the components again to rebuild its internal picture of the page, and connects it to the existing HTML.
It has three costs:
A hydration mismatch occurs when the server and the browser produce different output, for example from a date formatted in different time zones or a random value. Frameworks warn about it, and it can cause visible glitches.
Pages are rendered at build time. The output is a set of HTML files, deployed to a CDN.
Strengths
Weaknesses
Incremental static regeneration (ISR) softens the first two: pages are regenerated in the background after a set time or when content changes, so you get static speed with fresher data and no full rebuild.
| CSR | SSR | SSG | |
|---|---|---|---|
| HTML built | In the browser | On the server, per request | At build time |
| First content | Slow | Fast | Fastest |
| Time to first byte | Fast | Slower | Fastest |
| SEO | Weaker | Strong | Strong |
| Fresh data | Yes | Yes | Only as of the last build |
| Personalised content | Yes | Yes | Not in the HTML |
| Hosting | Static files | A server or serverless functions | Static files |
| Cost at scale | Low | Higher | Lowest |
These show up directly in the performance metrics. The web.dev article Rendering on the Web compares the options in terms of time to first byte, first contentful paint and interactivity. For how the browser turns the HTML into pixels, see how browsers render a web page.
Frameworks have spent the last few years reducing the cost of hydration.
The common theme: send less JavaScript, and do less work twice.
Search engines index HTML most reliably. Server-rendered and static pages put the content, title and metadata directly in the response.
With pure client-side rendering:
For content that needs to be found through search, such as articles, product pages and landing pages, render on the server or statically.
| Type of page | Good fit |
|---|---|
| Blog, documentation, marketing site | SSG, with ISR if content changes often |
| E-commerce product and category pages | SSG or ISR for the catalogue; SSR for live stock and prices |
| News or frequently updated public content | SSR with caching, or ISR |
| Logged-in dashboard, admin tool | CSR is fine; SEO is irrelevant |
| Highly interactive app (editor, design tool) | CSR, perhaps with a server-rendered shell |
| Personalised public pages | SSR, often streamed |
You rarely have to choose once for a whole site. Frameworks such as Next.js, Nuxt, SvelteKit, Remix and Astro let you pick per route. A typical site has static marketing pages, server-rendered product pages and a client-rendered account area.
Caching blurs the lines further: a server-rendered page cached at a CDN behaves much like a static one. See caching strategies.
window, localStorage) running on the server and crashing.In server-side rendering, the server sends complete HTML. In client-side rendering, the server sends JavaScript and the browser builds the HTML.
The process in which JavaScript takes over server-rendered HTML in the browser, attaching event handlers and state so the page becomes interactive.
Yes, generally. The content is in the initial HTML, which all crawlers can read without running JavaScript.
SSR builds the HTML for each request. SSG builds it once at build time and serves the same file to everyone.
Rendering strategy is a question of where and when HTML gets made. Static generation is fastest when content rarely changes, server rendering suits dynamic public pages, and client rendering suits private, highly interactive apps. Choose per page, cache what you can, and keep the JavaScript you send as small as the page allows.