Engrain by ByteRush

RCT.06.03 Senior· 13 minCore — asked often

React Server Components: components that never ship to the browser

Server vs client components, what "use client" really marks, which props can cross the boundary, the RSC payload, zero client JavaScript for server components, data fetching on the server, composition with children, and why RSC is not SSR.

Comes up in: React, Frontend system design

Learn#

Siddharth’s product page ships 180 KB of JavaScript, mostly a markdown parser and a date library used to show text that never changes. Every phone downloads and runs that code just to display static content.

A Server Component runs only on the server, or at build time. It can read databases and files directly, and its code is never sent to the browser; only its rendered output is. A Client Component also runs in the browser, so it can use state, effects and event handlers.

In frameworks that support RSC, components are server components by default. The “use client” directive at the top of a file marks the boundary: that file and what it imports become client code.

// ProductPage.jsx (Server Component: no directive)
import { db } from "./db";
import { AddToCart } from "./AddToCart";
export default async function ProductPage({ id }) {
  const product = await db.product.find(id); // runs on the server only
  return (
    <main>
      <h1>{product.name}</h1>
      <Markdown>{product.description}</Markdown>
      <AddToCart productId={product.id} price={product.price} />
    </main>
  );
}

The server sends an RSC payload: the server components’ output plus references to client components and their props.

A server page with one interactive islandStep 1 of 4

State

  • server: ProductPage, db.query(…)

Network

    empty

    Page

      empty

      ProductPage is a Server Component. It reads the product straight from the database on the server; the code and the DB client never reach the browser.

      Read the steps as text
      1. ProductPage is a Server Component. It reads the product straight from the database on the server; the code and the DB client never reach the browser.
      2. It renders <AddToCart productId={42} price={499} />. AddToCart's file starts with "use client", so here the server stops and leaves a reference to the client component.
      3. The server sends the RSC payload: the rendered server output plus client component references and their props.
      4. The browser downloads only AddToCart's JavaScript, renders it with those props, and makes it interactive. Description and specs ship as output, not code.

      Predict#

      Predict first

      A Server Component passes onClick={() => track('buy')} to a Client Component button. What happens?

      Interview angle#

      Say it like this — about 30 seconds

      “Server Components run only on the server and send rendered output, not code, so libraries they use add no client JavaScript, and they can fetch data directly. Client Components, marked with use client, run in the browser and can use state and effects. Props crossing from server to client must be serializable: primitives, plain objects, arrays, dates, promises and Server Functions, but not ordinary functions or class instances. RSC is not SSR: SSR turns components into HTML; RSC decides which components run where, and works with SSR.”

      Stays on your device. Nothing is uploaded.
      Follow-up What is the difference between SSR and React Server Components?
      SSR renders any components to HTML for the first load; RSC is a component type that never runs on the client, and its output can update without reloading.
      Follow-up What can and cannot be passed from a server component to a client component?
      Serializable values: primitives, plain objects and arrays, Date, Map, Set, promises, JSX and Server Functions. Not normal functions, class instances or symbols.
      Follow-up Can a client component import a server component?
      No. But a server component can pass server components to a client component as children or other props.

      Practice#

      On your own

      Write the check frameworks run on props that cross the server-to-client boundary.

      Done when

      • Serializable values pass, including nested arrays, Dates, Maps, Sets and promises.
      • The first plain function, class instance or symbol is reported with its path and reason.
      • Server Functions are allowed.
      Your solution
      Ctrl/⌘ + Enter

      Remember#

      Try to answer each card before you open it. Then add them to your reviews.

      Where does a Server Component's code run?

      Only on the server (or at build time); it never ships to the browser.

      What does "use client" mark?

      The boundary where a file and its imports become client code.

      Can a Server Component pass an onClick function to a Client Component?

      No, unless it is a Server Function; plain functions are not serializable.

      How can a client component render a server component?

      Receive it as children or another JSX prop from a server component.

      Go deeper

      Four layers. Stop at the one your interview needs; each ends with a quick check.

      The core ideaEvery round
      Server components can be async and await data directly, without effects or loading states in the browser. They cannot use state, effects or browser APIs.
      Libraries used only in server components add zero client JavaScript.
      Check yourself: Can a Server Component use useState?

      No. State and effects need the browser, so they belong in client components.

      How it works underneathSenior rounds

      The payload is a streamed description of the tree. Where a client component appears, it holds a reference to its module and export plus its serialized props; the browser loads that module and renders it Source: React: Server Components.

      Check yourself: What does a client component reference in the RSC payload contain?

      Which module and export to load, plus its serialized props.

      Edge cases and trapsWhere people slip

      A client component cannot import a server component, but it can receive one as children: <ClientTabs><ServerPanel /></ClientTabs>. The server renders the panel; the client places it.
      Mark only the boundary file; its imports follow.

      Check yourself: Is the use client directive needed on every client file?

      No. Only at the entry file of the boundary; its imports are client code too.

      In productionStaff-level answers

      RSC and SSR are complementary: on the first load the server runs both, producing HTML; on navigation it sends only a new RSC payload.
      Keep secrets out of props: everything passed to a client component is sent to the browser Source: React: 'use client'.

      Check yourself: Do RSC and SSR compete?

      No. They work together: RSC splits the work, SSR produces first-load HTML.

      Finished the five steps? Mark it, and its cards join your reviews.

      Last checked 2026-11-01. Spot a mistake? Use “Report an error” below — fixes are listed on the corrections page.

      Interview questions this answers

      • What is the difference between SSR and React Server Components?
      • What can and cannot be passed from a server component to a client component?
      • Can a client component import a server component?