Rendering Strategies

CSR, SSR, SSG, ISR, streaming and React Server Components, hydration and its costs, islands architecture, edge rendering, and how to choose the right strategy for each page.

Intermediate 4 min readLesson 8 of 14 Interview Q&A

Where and when HTML gets generated is one of the biggest architectural decisions in a web app. It affects load speed, SEO, server cost, complexity and how fresh the data is.

The strategies

StrategyHTML generatedGood forWatch out for
CSR — client-side renderingIn the browser, by JS, after loadDashboards behind login, highly interactive appsBlank page until JS loads; weaker SEO; big bundles
SSR — server-side renderingOn the server, per requestPersonalised or fast-changing pages that need SEOServer cost per request; TTFB depends on data fetching
SSG — static site generationAt build timeDocs, blogs, marketing, this siteRebuild to update; build time grows with pages
ISR — incremental static regenerationAt build, then re-generated in the background after a revalidation period or on demandLarge catalogues, content that changes occasionallyBriefly stale data
Streaming SSROn the server, sent in chunks as data resolvesPages with slow and fast partsNeeds framework support

CSR

Browser → GET /          ← <div id="root"></div> + <script src="app.js">
Browser → GET app.js     ← 400 KB of JS
         (parse, execute, fetch data)
         → content finally visible

SSR

Browser → GET /product/42
Server:  fetch data → render components to HTML
         ← full HTML (content visible immediately) + JS
Browser: download JS → hydrate → interactive

SSG

Build:   for each page: fetch data → render HTML → write file → deploy to CDN
Browser → GET /docs/intro ← prebuilt HTML from the nearest CDN edge (very fast)

Hydration

SSR and SSG pages arrive as HTML, but buttons don't work until JavaScript hydrates them: React re-runs the components in the browser, attaches event listeners, and reconciles with the existing DOM.

HTML arrivesVisible (FCP)JS downloadHydrationInteractive00.40.61.62.22.5

Costs of hydration:

  • Uncanny valley: content is visible but not interactive.
  • Double work: the server renders, then the client re-runs the same components.
  • Bundle size: all component code ships to the browser, even for static parts.
  • Hydration mismatches: if server and client render differently (dates, Math.random(), window checks), React warns and may re-render.

Reducing hydration cost

React Server Components (RSC)

Components are split into two kinds:

  • Server Components (the default in Next.js App Router): run only on the server (or at build). They can be async, read databases and files directly, and their code never ships to the browser — they send a serialised result.
  • Client Components ("use client"): ship to the browser and hydrate; they can use state, effects and event handlers.
TSX
// app/products/[id]/page.tsx — a Server Component
export default async function ProductPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const product = await db.product.findUnique({ where: { id } });   // direct DB access
  return (
    <article>
      <h1>{product.name}</h1>
      <Markdown source={product.description} />    {/* heavy library stays on the server */}
      <AddToCartButton productId={id} />           {/* the only Client Component */}
    </article>
  );
}

// AddToCartButton.tsx
"use client";
export function AddToCartButton({ productId }: { productId: string }) {
  const [pending, setPending] = useState(false);
  return <button disabled={pending} onClick={…}>Add to cart</button>;
}

Only the interactive leaves ship JavaScript.

Streaming with Suspense

Send the page shell immediately and stream slow sections as their data resolves:

TSX
<Layout>
  <ProductDetails id={id} />                {/* fast */}
  <Suspense fallback={<ReviewsSkeleton />}>
    <Reviews id={id} />                     {/* slow: streamed in later */}
  </Suspense>
</Layout>

Islands architecture

Frameworks like Astro render pages as static HTML and hydrate only the interactive "islands" (a carousel, a search box). Ideal for content-heavy sites. Qwik goes further with resumability: no hydration; event handlers load lazily on interaction.

Edge rendering

Run SSR on servers at CDN edge locations close to users (Cloudflare Workers, Vercel Edge, Deno Deploy) for low TTFB worldwide. Trade-off: edge runtimes are limited (no full Node APIs) and the database is usually still in one region — rendering at the edge but querying a distant DB can be slower than rendering near the DB. Pair edge rendering with edge caches or replicated data (Serverless and edge).

Choosing

PageStrategy
Marketing, docs, blogSSG (rebuild or ISR on content change)
E-commerce product pageSSG/ISR for content + client-side or streamed price/stock
Search results, news feedSSR (streaming)
Logged-in dashboardCSR or SSR shell + client data fetching
Real-time collaborative editorCSR (the app is the page)

Modern frameworks (Next.js, Remix/React Router, Nuxt, SvelteKit, Astro) let you choose per route.

Key takeaways
  • CSR renders in the browser; SSR per request on the server; SSG at build time; ISR regenerates static pages in the background.
  • Hydration makes server HTML interactive but costs JS download and double rendering.
  • Server Components keep non-interactive code on the server; only Client Components ship JS.
  • Streaming with Suspense sends the shell first and fills slow parts later.
  • Islands and resumability minimise hydration; edge rendering cuts latency if data is close too.
  • Pick the strategy per page based on freshness, personalisation, SEO and interactivity.
Interview questions
QWhat is hydration and why can it hurt performance?medium

Hydration is the client-side process where JavaScript re-runs the components that produced server-rendered HTML, attaches event handlers, and takes over the DOM. Until it finishes, the page looks ready but isn't interactive. It requires downloading and executing the code for every component on the page — even purely static ones — and repeats rendering work the server already did. Server Components, islands, partial or progressive hydration, and resumability all aim to reduce this cost.