JS Guide
HomeQuestionsTopicsCompaniesResources
BookmarksSearch

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionssystem-design
PrevNext

Learn the concept

Rendering Strategy Architecture

system-design
junior
rendering

What are the trade-offs between client-side and server-side rendering?

csr
ssr
ssg
isr
rendering
hydration
seo
performance
Quick Answer

Client-side rendering (CSR) sends a minimal HTML shell and renders everything in the browser via JavaScript — fast TTFB but slow first paint and poor SEO. Server-side rendering (SSR) generates full HTML on the server — slower TTFB but fast first paint and good SEO. Modern apps often use hybrid approaches where different routes use different strategies.

Detailed Explanation

The rendering strategy you choose is one of the most impactful architectural decisions in frontend development. It affects how fast users see content, how search engines index your pages, what infrastructure you need, and how complex your codebase becomes.

Client-Side Rendering (CSR)

In CSR (traditional single-page application approach), the server sends a nearly empty HTML file with a <script> tag. The browser downloads and executes the JavaScript, which then renders the entire UI.

The loading sequence:

  1. Browser requests index.html — receives a minimal shell (<div id="root"></div>)
  2. Browser downloads the JavaScript bundle (could be 200KB-2MB)
  3. JavaScript executes, makes API calls to fetch data
  4. React renders the UI into the DOM
  5. Page is now visible and interactive

Advantages:

  • Simple deployment — Just static files (HTML, JS, CSS) on a CDN. No server runtime needed.
  • Rich interactivity — After initial load, navigation is instant (no full page reloads)
  • Lower server cost — No per-request server rendering. The CDN handles everything.
  • Great for authenticated apps — Dashboards, admin panels, and tools where SEO doesn't matter

Disadvantages:

  • Slow initial load — Users see a blank white screen until JavaScript downloads, parses, and executes. On slow connections or low-end devices, this can take several seconds.
  • Poor SEO — Search engine crawlers may not execute JavaScript. Google's crawler does (with delays), but other search engines may not index CSR content at all.
  • Loading waterfall — HTML → JS → API data → render. Each step must complete before the next starts.
  • Large bundles — All rendering logic ships to the client. Without code splitting, bundle size grows with every feature.

Server-Side Rendering (SSR)

In SSR, the server executes the React application and sends fully rendered HTML to the browser.

The loading sequence:

  1. Browser requests a page — server runs React, calls APIs, generates complete HTML
  2. Browser receives full HTML — user sees the content immediately
  3. Browser downloads the JavaScript bundle in the background
  4. Hydration — React attaches event handlers to the existing server-rendered HTML
  5. Page becomes interactive

Advantages:

  • Fast First Contentful Paint (FCP) — Users see content as soon as HTML arrives, before JavaScript loads
  • Good SEO — Crawlers receive complete HTML with all content. No JavaScript execution required.
  • Better perceived performance — Even though total load time may be similar, seeing content early makes the app feel faster
  • Social sharing — Open Graph meta tags are in the initial HTML, so link previews work correctly on social media

Disadvantages:

  • Slower TTFB — The server must render the page before sending the response. Complex pages with data fetching can take 100ms-2s.
  • Server infrastructure — Requires a Node.js server (or serverless functions) that can run React. More operational complexity than static files.
  • Hydration cost — The JavaScript bundle still needs to download and execute to make the page interactive. During hydration, the page looks interactive but isn't — clicks may not work yet (the "uncanny valley" of SSR).
  • Server load — Each request requires server CPU to render. High traffic needs more server capacity.

Beyond CSR and SSR: Other Strategies

Static Site Generation (SSG) — Pages are rendered at build time, not request time. Combines SSR's SEO benefits with CDN's speed. Best for content that doesn't change often (blogs, docs, marketing pages).

Incremental Static Regeneration (ISR) — SSG with background revalidation. Pages are static but refresh automatically after a time period. Best for semi-dynamic content (product pages, news articles).

Streaming SSR — Server sends HTML progressively as it renders. The browser shows early content while waiting for slower data. Uses React Suspense boundaries to define streaming chunks.

React Server Components (RSC) — Components run on the server and send rendered output (not JavaScript) to the client. Server Component code never reaches the browser, dramatically reducing bundle size. Client Components handle interactivity.

How to Choose

| Scenario | Best Strategy | Why | |----------|---------------|-----| | Blog / documentation | SSG | Content rarely changes, SEO critical | | E-commerce product page | ISR | SEO critical, content changes occasionally | | Social media feed | Streaming SSR | Personalized, SEO helpful, data-heavy | | Admin dashboard | CSR | Authenticated, no SEO, rich interactivity | | Marketing landing page | SSG | Performance critical, static content | | Real-time chat | CSR | Highly interactive, no SEO need |

Most modern applications use hybrid rendering — Next.js allows different routes to use different strategies within the same app.

Key Interview Distinction

CSR and SSR are not either/or — they're ends of a spectrum. CSR optimizes for simplicity and interactivity at the cost of initial load speed and SEO. SSR optimizes for fast first paint and SEO at the cost of server complexity and hydration overhead. Modern frameworks (Next.js, Remix) enable per-route rendering strategies so you can choose the best approach for each page.

Code Examples

Client-side rendering: React SPA entry pointJSX
// CSR: The server sends this minimal HTML
// <html>
//   <body>
//     <div id="root"></div>
//     <script src="/bundle.js"></script>
//   </body>
// </html>

// bundle.js does ALL the rendering
import { createRoot } from 'react-dom/client';
import { BrowserRouter, Routes, Route } from 'react-router-dom';

function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/products" element={<Products />} />
        <Route path="/dashboard" element={<Dashboard />} />
      </Routes>
    </BrowserRouter>
  );
}

// Nothing renders until this JS downloads and executes
const root = createRoot(document.getElementById('root'));
root.render(<App />);

// Timeline:
// 1. Empty HTML loads instantly (fast TTFB)
// 2. JS bundle downloads (could be 500KB+)
// 3. JS executes, fetches data, renders UI
// 4. User finally sees content (slow FCP)

Real-World Applications

Use Cases

E-commerce Product Pages

Using ISR to serve product pages with static performance while keeping prices and availability fresh — pages revalidate every few minutes without requiring full rebuilds

SaaS Dashboard

Using CSR for authenticated dashboards where SEO doesn't matter — rich client-side interactivity with real-time data updates and no server rendering overhead

Content Marketing Sites

Using SSG for blog posts and landing pages that rarely change — pre-built HTML served from CDN gives the fastest possible load time and perfect SEO

Mini Projects

Rendering Strategy Comparison

intermediate

Build the same page three ways (CSR with Vite, SSR with Next.js, SSG with Next.js) and measure TTFB, FCP, LCP, and TTI with Lighthouse to see the real-world differences

Hybrid Next.js App

intermediate

Build a Next.js app that uses SSG for the landing page, ISR for a product catalog, SSR for a personalized feed, and CSR for a settings page — demonstrating per-route rendering strategies

Industry Examples

Netflix

Switched their landing page from CSR to SSR to reduce Time to Interactive by 50% on mid-range mobile devices — users could read content while JavaScript loaded in the background

Vercel

Next.js supports all rendering strategies (CSR, SSR, SSG, ISR, streaming, RSC) within a single app — enabling per-route optimization based on each page's requirements

Shopify

Uses SSR with streaming for their Hydrogen framework (React-based storefront) to deliver fast initial content for product pages while loading interactive elements progressively

Resources

Next.js Docs — Rendering

docs

web.dev — Rendering on the Web

article

MDN — Server-Side Rendering

docs
Previous
How do you approach a frontend system design interview?
Next
What makes a good component API for a design system?
PrevNext