← Back to React, page 1

react-0016 · Hard senior

What are React Server Components, how do they differ from client components and server-side rendering, and what are their limits?

Server Components render only on the server, at build time or per request. Their code and their own dependencies are not sent to the browser, and they can be async and read data directly. Client components, marked with "use client", run in the browser and hold state, effects and event handlers. Server-side rendering is a different idea: it turns components into HTML for the first load, and then the client code hydrates.

Full answer

Two ideas are often mixed up. Server-side rendering (SSR) produces HTML for the first response, and the page then loads its JavaScript and hydrates, so every component's code still ships to the browser. React Server Components (RSC) decide where a component runs. A Server Component never runs in the browser at all.

A Server Component can be an async function, call a database, read a file or use a secret key, because it executes on the server. React sends the result as a serialized description (the RSC payload), which the client merges into the tree. A large library used only inside a Server Component, such as a markdown parser, is not added to the bundle.

A Client Component starts with the "use client" directive at the top of its file. It can use state, effects, refs, event handlers and browser APIs. Client Components are still pre-rendered to HTML on the server for the first load, then hydrated.

The rules follow from where code runs. A Server Component cannot use useState, useEffect or onClick, and cannot read window. A Client Component cannot import a Server Component, but it can receive one as children or another prop, since that is passed as already rendered output. Props that cross from server to client must be serializable: plain data, not functions (except Server Functions), classes or open connections.

Do not say a page sends "zero JavaScript". Client Components, the framework runtime and React still ship. The saving is the code that stays on the server.

RSC needs a framework or bundler integration, such as the Next.js App Router. Server Actions (functions marked "use server") are callable from the client and are public HTTP endpoints, so they need validation and authorization. In December 2025 React disclosed a critical remote code execution flaw in Server Components, fixed in 19.0.1, 19.1.2 and 19.2.1, so keep server packages updated.

The Server Component below is run here by calling it and rendering the result to static HTML, since a real RSC runtime needs a framework.

jsx
function getMarks() {
  // Stands in for a database call that only the server can make.
  return Promise.resolve([
    { id: 1, name: 'Asha', marks: 82 },
    { id: 2, name: 'Ravi', marks: 47 },
  ]);
}

function Scoreboard({ rows }) {
  return (
    <ul>
      {rows.map((row) => (
        <li key={row.id}>
          {row.name}: {row.marks}
        </li>
      ))}
    </ul>
  );
}

export default async function ResultsPage() {
  const rows = await getMarks();
  return (
    <main>
      <h1>Results</h1>
      <Scoreboard rows={rows} />
    </main>
  );
}

ResultsPage is an async component: it awaits data before returning JSX, which only a Server Component may do. This file has no hooks and no event handlers. The check awaited the function and rendered its result to static HTML, which is not the same as a full RSC runtime. Result: <main><h1>Results</h1><ul><li>Asha: 82</li><li>Ravi: 47</li></ul></main>

Key points

  • SSR creates first-load HTML and still ships and hydrates the component code. RSC keeps component code on the server.
  • Server Components may be async and read data directly, but have no state, effects or browser APIs.
  • "use client" marks the boundary where client code begins. Props crossing it must be serializable.
  • Only code that stays on the server is saved. Pages still ship JavaScript for client components.
  • Server Actions are public endpoints and need validation and authorization.

Common mistakes

  • Calling useState, useEffect or onClick inside a Server Component.
  • Putting "use client" at the top of every file, which removes the benefit.
  • Importing a Server Component into a Client Component instead of passing it as children.
  • Passing a function or a class instance from a Server Component to a Client Component.
  • Trusting a Server Action as if it were only called by your own UI.

Follow-ups

  • How do Server Components and Suspense work together when streaming a page?
  • Why can a Client Component receive a Server Component as children?
  • How do you secure a Server Action?

Tips

  • Separate SSR and RSC in your first two sentences. It is the most common confusion.
  • Say what is saved and what still ships. Avoid "no JavaScript".
  • Mention that it needs a framework, and name Next.js App Router as the usual route.