CSR · SSR · SSG · ISR · RSC

Where does a page get put together: in the browser, on the server every time, at build time, at build time and then rebuilt on a schedule, or sent in parts? Watch the same page load all five ways, then set the network, the device and the traffic yourself.

Level: IntermediateWatch: 15 steps · ~75 secondsSet the network, device and trafficRecall: 3 questions · 8 cardsCompare all 5 at onceTypeScript · React · Next.js 16

What you'll take away

  • Tell CSR, SSR, SSG, ISR and RSC apart by where and when the HTML is put together
  • Explain why a server-rendered page shows early but can't be clicked until it hydrates
  • Pick a mode by how fresh the data must be and whether each visitor sees something else
  • Make parts of a Next.js 16 page static or per request with "use cache" and Suspense

The 1-minute version

Tap a point and the picture below plays that step.

4Compare them all
CSRHTML made in the browser
blank screen
CDN
origin server · APIserverprice 59
t = 0 ms (simulated)
phone → CDN: the page? → …
Step 1 / 15 · step by step
60 msTTFB
442 mscontent shows
442 mstappable
180 KBJavaScript
120 msserver per request

The visitor's phone stands at the near end of the street, a CDN just along it, the origin server at the far end. A blue light is a request, teal is HTML, violet is JavaScript, lavender is data. The card above the phone is its screen; a gold slab on the CDN is a page built ahead of time; a bar on a roof is that place at work, and “HTML made here” marks where each step put the page together. Every time comes from a model (lib/modes.ts), not from real measurements.

Step 4 · Every option at once, on one clock

Compare them all: CSR · SSR · SSG · ISR · RSC

The same product page loading five ways at once, on the same network and device. Blue = waiting, green = HTML arriving, purple = JavaScript, gray = the server working. Lines: TTFB, content, tappable.

0 ms (simulated)
CSRHTML made: in the browsercontent 442 ms · tappable 442 ms · JS 180 KB · server 120 ms per request · data fresh

Use it when Pages behind a login that don't need to be found by search and do a lot of interaction (dashboards)

Skip it when A landing page that has to be fast and found by search: the screen stays empty until the JavaScript has loaded and fetched the data

A model: fast network RTT 40 ms ~10 Mbps, slow RTT 300 ms ~0.5 Mbps, slow device = CPU 4× slower, 120 ms for the data on the server. Not a real measurement. Press any tile to see it large above, with when it fits.

Five names for one question: where and when is the HTML put together?

ModeHTML madeData
CSRin the browser, after the JS runsfresh (the browser fetches it)
SSRon the server, every requestfresh
SSGat build timeas old as the build
ISRat build time + rebuilt on a scheduleabout one period old while visits keep coming; a quiet page can be older
RSC + streamingon the server, sent in partsyou choose, part by part

Hydration

HTML from the server shows right away, but you can't click it until the JavaScript loads and attaches its events. The bigger the JS and the slower the device, the longer that "you can see it but not click it" stretch lasts. Server Components help because they send none of their own JS.

Next.js 16

In the App Router, every page is a Server Component already. With Cache Components on, the parts marked "use cache" with cacheLife are static (SSG / ISR on the period you set), and the parts that read data after await connection() happen at request time and should sit in Suspense so they stream in after. The code in this lesson follows the docs that ship with Next.js 16.4, which this site uses.

In real code

csr.tsx
// CSR: the server sends an empty shell and JavaScript; the browser fetches the data and draws the page.
// Next.js 16 (App Router): a Client Component. Compiled against the installed Next / React types; not run.
"use client";

import { useEffect, useState } from "react";
import type { Product } from "./data";

export function ProductCSR({ id }: { id: string }) {
  const [product, setProduct] = useState<Product | null>(null);

  useEffect(() => {
    let live = true;
    fetch(`/api/products/${id}`)
      .then((res) => res.json() as Promise<Product>)
      .then((p) => { if (live) setProduct(p); });
    return () => { live = false; }; // the id changed or the page left: ignore the old answer
  }, [id]);

  if (!product) return <p>กำลังโหลด…</p>; // what the first paint shows
  return <h1>{product.name} · {product.price} บาท</h1>;
}
Run: tsc against the Next.js / React this site has installed (compiled only, not run)

A Client Component: it fetches the data in useEffect after the JavaScript runs. Compiled against the types of the Next.js 16 and React 19 this site has installed; not run.

Common questions

How do CSR, SSR and SSG differ?

In where the HTML gets put together. CSR does it in the browser after the JS runs, SSR on the server for every request, SSG once at build time. ISR is SSG that gets rebuilt in the background once a set period has passed.

Table: where the HTML is made

So which one should I use?

Ask how fresh the data must be and whether it differs per visitor. Pages that hardly change, like articles: SSG. Fine being a minute old, like product pages: ISR. Fresh every time, or different per person: SSR. Behind a login with no need for search: CSR is fine.

What is hydration, and why can I see the page but not click it?

HTML from the server is only the look; nothing is wired up yet. The browser has to download the JS and run it so React can attach the events to that HTML. Until then you can see it but not click it, and a big bundle or a slow device makes that longer.

What is TTFB, and which mode is slowest at it?

Time To First Byte: how long until the first byte of HTML arrives. SSR waits for the server to fetch the data and render, so it's the slowest. SSG, ISR and CSR come from a CDN and are fast, though CSR's quick first byte still has no content in it.

SSG goes stale. How does ISR help?

ISR still serves a static page from the CDN. Once the period you set has passed (60 seconds, say), the next visit sets off a rebuild in the background: that visitor still gets the old page, the ones after get the new one, with no build of the whole site.

What do Server Components and streaming help with?

Server Components render only on the server and send none of their own JS, so there's less to download and hydrate. Streaming means the server sends the shell first and the parts waiting on data follow as later chunks, so nobody waits for the slowest part.

In Next.js 16, how do I make a part static, or fresh on every request?

Every page in the App Router is a Server Component already. Parts marked "use cache" with cacheLife are static (give it a revalidate period and that's ISR). Parts that read data after await connection() happen at request time and should sit in Suspense so they stream in after.

Next lesson

Event loopLevel: Intermediate

Hydration runs on JavaScript's one thread; next, the event loop, and why one long task on it keeps every click waiting.