React Curriculum

React Server Components (RSC): Architecture & Mental Model

Hard100% Free~30 mins#react#rsc#server-components#use-client#zero-bundle-size#nextjs
Interview Answer (30-Second Summary)

React Server Components (RSC) execute exclusively on the server with zero client JavaScript bundle cost and direct database access. Client Components ("use client") provide interactivity. The server streams a serialized JSON-like virtual DOM payload that integrates seamlessly into the client tree.

Key Learning Objectives
✓

Distinguish React Server Components (RSC) from traditional SSR: zero bundle size vs initial HTML.

✓

Explain what the "use client" directive actually means: an entry point to the client bundle boundary.

✓

Identify what can and cannot be done in Server Components (no hooks, no event listeners, direct DB access).

✓

Pass Server Components as children/props to Client Components to preserve zero-bundle-size benefits.

The Interview Problem & Context

Explain why Server Components add 0KB of JavaScript to the client bundle, what "use client" actually signifies, and how to compose Server Components inside Client Components.

1// 1. SERVER COMPONENT (Default in Next.js App Router)
2// Runs ONLY on server: Direct DB access, 0KB JS in client bundle!
3import db from '@/lib/db';
4import { ClientSearchDrawer } from './ClientSearchDrawer';
5
6export async function ProductDashboard() {
7 // Direct async await database query inside component!
8 const products = await db.products.findMany({ take: 10 });
9
10 return (
11 <div className="dashboard">
12 <h1>Catalog Overview</h1>
13
14 {/* Composing Server Component children inside a Client Component */}
15 <ClientSearchDrawer>
16 {/* This child still executes on the server! Zero bundle cost! */}
17 <ProductGrid products={products} />
18 </ClientSearchDrawer>
19 </div>
20 );
21}
22
23// 2. SERVER COMPONENT: Zero JS sent to client
24function ProductGrid({ products }: { products: any[] }) {
25 return (
26 <ul>
27 {products.map((p) => (
28 <li key={p.id}>{p.name} - ${p.price}</li>
29 ))}
30 </ul>
31 );
32}
33
34// 3. CLIENT COMPONENT (Must specify "use client" directive)
35// 'use client';
36// export function ClientSearchDrawer({ children }: { children: React.ReactNode }) {
37// const [isOpen, setIsOpen] = useState(false);
38// return (
39// <div>
40// <button onClick={() => setIsOpen(!isOpen)}>Toggle Drawer</button>
41// {isOpen && <aside>{children}</aside>}
42// </div>
43// );
44// }
Deep Architectural Explanation

The React Server Components (RSC) Revolution

1. Zero Client Bundle Overhead:

When you import a heavy 50KB library (like a markdown parser or heavy database driver) inside a Server Component:

  • The library is executed on the server to generate UI.
  • The library code is never downloaded by the user browser.
  • The client receives only the serialized RSC payload (representing the rendered virtual DOM tree).

2. What "use client" Really Means:

A common interview misconception is thinking "use client" means "client-only".

  • Reality: "use client" defines a boundary marker.
  • Everything above the boundary is a Server Component.
  • Everything below the boundary is part of the client JavaScript bundle.
  • Client Components still pre-render to HTML on the server during SSR! "use client" just means "ship this component JavaScript to the browser so it can be interactive."

3. Composition Rule (Server inside Client):

A Client Component cannot directly import a Server Component (because the client bundle cannot execute server code).
However, a Server Component can pass another Server Component into a Client Component as children or props:
Example: ClientModal wrapping ServerHeavyAnalyticsTable.
The ServerHeavyAnalyticsTable is rendered on the server, serialized, and passed into ClientModal as rendered React elements!

Common Interview Traps & Pitfalls
✕

Believing "use client" components do not render on the server during initial page load.

✕

Trying to use useState, useEffect, or onClick inside a Server Component.

✕

Importing a Server Component directly into a Client Component file.

Senior Interviewer Follow-Up Probes
?

What is the structure of the RSC payload stream sent over the network?

?

How do Server Actions ("use server") enable RPC-style form mutations without custom REST APIs?

?

How does Next.js cache Server Component results using the Data Cache and Full Route Cache?

Frequently Asked Interview Questions
What is the main advantage of React Server Components (RSC)?

Zero client-side JavaScript bundle cost for server components, direct access to server-side resources (databases, internal microservices), and automatic code-splitting.

Traditional SSR sends HTML for the initial page load, but still downloads JavaScript for the entire component tree to hydrate. RSC runs components on the server permanently; their JavaScript is never sent to the browser.

It marks the boundary where execution transitions from server-only components to client components, adding that module and its dependencies to the client JavaScript bundle.

No. Server components execute once on the server and do not retain client-side memory or lifecycle events. Interactive state requires a Client Component.

Pass the Server Component as children or a JSX slot prop from an outer Server Component into the Client Component.

No. All props passing across the server-client boundary must be serializable (primitives, plain objects, arrays, JSX). Functions cannot be serialized, except Server Actions.