Skip to solution
hardFrontend

React Server Components vs SSR — what is the real difference?

710 views
01

Understand the problem

Question presented to candidate: "Server-side rendering already runs components on the server. So what do Server Components add?"

What a strong answer should cover:

  • They are different axes, not competing options. SSR is about when the HTML is produced; RSC is about whether a component's code ever reaches the browser.
  • SSR runs your components on the server to produce HTML, then ships the same components again in the bundle so they can hydrate. The code goes over the wire twice.
  • RSC components run on the server and never enter the client bundle at all. They emit a serialised description of UI, not HTML, and not JavaScript.
  • So RSC's headline win is bundle size — a markdown renderer, a date library, a database client can stay entirely on the server.
  • Server Components can be async and read data directly (a database, the filesystem) because there is no client render to restart.
  • They have no state, no effects, no event handlers, and no hooks that need them. Anything interactive is a Client Component, marked with "use client".
  • The boundary is one-way for code but not for composition: a Server Component can render a Client Component and pass it props — including an unresolved promise the client reads with use().
  • They are normally used together: RSC decides what ships, SSR still produces the initial HTML for the client parts.

Clarifying questions expected:

  • "Are we talking about bundle size or time-to-first-byte?" — RSC addresses the first, SSR the second.
  • "Which framework?" — RSC needs a bundler-integrated runtime, not just React.

Code / implementation expected: No. Naming what crosses the boundary is the answer.

reactrscssr
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Target Audience: Engineers preparing for senior React interviews — assumes SSR. Difficulty: Hard

How to read this doc: Concepts are explained in plain language first, then tagged with 📌 Interview term:. **A note on v

Solution ready — 2 min read

Classified // press E to declassify

04

Explore the playground snippets

The boundary written out: what ships, what does not, and what can cross
Run Playground
import { useState } from "react";

// This playground has no RSC runtime — react-server-dom-webpack is not
// installed, and a Server Component needs a bundler-integrated server. So this
// is an ANNOTATED reference of the boundary rather than a running one, plus a
// live demo of the one part that does work in a browser: passing an unresolved
// promise into a component that reads it.

const SERVER_COMPONENT = `// app/product/[id]/page.jsx  — NO "use client"
// Runs on the server. Its code never enters the client bundle.
import { marked } from "marked";        // ~40KB, stays on the server
import { db } from "@/lib/db";          // never shipped to the browser

export default async function ProductPage({ params }) {
  //  async is allowed: a server render happens once and is never re-entered
  const product = await db.product.findUnique({ where: { id: params.id } });

  return (
    <article>
      <h1>{product.name}</h1>

      {/* marked runs here; the browser never downloads it */}
      <div dangerouslySetInnerHTML={{ __html: marked(product.description) }} />

      {/* A CLIENT component. Only THIS subtree ships. */}
      <AddToCart productId={product.id} price={product.price} />

      {/*  a function cannot cross the boundary:
          <AddToCart onAdd={() => ...} />   -> not serialisable */}
    </article>
  );
}`;

const CLIENT_COMPONENT = `// components/AddToCart.jsx
"use client";                    // <- the boundary. Everything this imports ships.
import { useState } from "react";

export default function AddToCart({ productId, price }) {
  const [qty, setQty] = useState(1);      // state: only possible here
  return (
    <div>
      <input value={qty} onChange={(e) => setQty(+e.target.value)} />
      <button onClick={() => addToCart(productId, qty)}>Add · {price * qty}</button>
    </div>
  );
}`;

const TABS = [
  ["Server Component", SERVER_COMPONENT, "#eef7ee"],
  ["Client Component", CLIENT_COMPONENT, "#eef"],
];

export default function App() {
  const [tab, setTab] = useState(0);

  return (
    <div style={{ padding: 24, fontFamily: "system-ui", lineHeight: 1.6, maxWidth: 620 }}>
      <div style={{ display: "flex", gap: 8, marginBottom: 10 }}>
        {TABS.map(([label], i) => (
          <button key={label} onClick={() => setTab(i)} style={{ fontWeight: i === tab ? "bold" : "normal" }}>
            {label}
          </button>
        ))}
      </div>

      <pre style={{ background: TABS[tab][2], border: "1px solid #ddd", borderRadius: 8,
                    padding: 12, fontSize: 12, overflowX: "auto", whiteSpace: "pre-wrap" }}>
{TABS[tab][1]}
      </pre>

      <div style={{ border: "1px solid #ddd", borderRadius: 8, padding: 12, marginTop: 10, fontSize: 13 }}>
        <strong>What crosses the boundary</strong>
        <table style={{ width: "100%", fontSize: 12, marginTop: 6, borderCollapse: "collapse" }}>
          <tbody>
            {[
              ["strings, numbers, plain objects, arrays", "✅ crosses"],
              ["an unresolved promise (read with use())", "✅ crosses"],
              ["rendered children as a prop", "✅ crosses"],
              ["a function or event handler", "❌ not serialisable"],
              ["a class instance, a Date method, a Map", "❌ not serialisable"],
            ].map(([what, ok]) => (
              <tr key={what}>
                <td style={{ padding: "2px 8px 2px 0" }}>{what}</td>
                <td style={{ color: ok.startsWith("✅") ? "#161" : "#a33" }}>{ok}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>

      <p style={{ fontSize: 13, color: "#666" }}>
        The asymmetry to remember: <code>marked</code> and the database client in
        the first tab never reach the browser at all, while under plain SSR every
        component that renders HTML must also ship as JavaScript so it can
        hydrate. That is the bundle-size difference RSC is actually about.
      </p>
    </div>
  );
}
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 89 of 119 decoded in the React.js track. One more won't hurt.

Back to track