What the user sees first
Browser-readable markup that shows a quick, non-interactive version of the page. It is not the RSC payload.
Lesson 04 · Advanced frontend rendering
Estimated time: about 14 minutes
RSC is not another word for SSR. It partitions the module graph: some component code executes only in a server environment, while explicit client entry points ship for interaction.
In plain English: Server Components let you keep data-fetching and private server work on the server, while sending only the interactive pieces to the browser. The boundary is a design choice, not a magic performance switch.
On a first page load, Next.js uses three related things for different jobs. Keeping them separate makes it easier to understand what the user sees first and when the page becomes interactive.
Browser-readable markup that shows a quick, non-interactive version of the page. It is not the RSC payload.
Compact data that describes the server-rendered component tree, including references to Client Components and their props. React uses it to match the server and client trees.
JavaScript for the Client Components. React uses it to attach event handlers and make those parts interactive; this step is called hydration.
Run in the framework’s server environment at build time or request time. They may await data and use server-only dependencies, but cannot hold browser state or event handlers.
Belong to the client module graph and can use state, effects, context, handlers, and browser APIs. On an initial visit, a framework may still use them while producing HTML.
Async server endpoints referenced from client code, often for mutations. 'use server' marks these functions—it does not mark a Server Component.
An optional HTML-generation step. Server Component output can be SSR’d, prerendered at build time, streamed, cached, or requested during client navigation.
'use client' marks a module entry point and its transitive dependencies for client evaluation. It is not a label that affects only the component function in that file.
Boundary at ProductPage
Observe which modules become browser code.
8 modules in the illustrative client graph.
Invalid graph: the browser subtree now reaches a server-only database module.
A Server Component can render a Client Component and pass supported serializable values across the boundary.
The client module graph cannot execute a Server Component module. Compose it in a server parent and pass its rendered element through a slot such as children.
Values passed into a Client Component are serialized for the browser. Server access is safe; sending secrets or excess records as props is not.
Context requires a Client Component. Wrap only the subtree that consumes it so unrelated modules and static work remain outside the client boundary.
// Server Component
export default async function ProductPage({ id }) {
const product = await db.product.find(id);
return (
<ProductView description={product.description}>
<Gallery images={product.images} /> {/* client */}
<CartButton productId={product.id} /> {/* client */}
</ProductView>
);
}
| Claim | Correction |
|---|---|
| “Client Components only render in the browser.” | They ship to the browser, but an RSC framework can also use them to produce initial HTML before hydration. |
| “Server Components require a live server.” | They may execute during the build and produce static output; “server” names the environment, not necessarily request timing. |
“Add 'use client' wherever hooks appear.” | Add it at client entry points. Modules already below that boundary are client modules without repeating the directive. |
“'use server' marks a Server Component.” | There is no Server Component directive. 'use server' exposes an async Server Function reference. |
| “Server code means secrets are automatically safe.” | Imports can remain server-only, but props and Server Function results are serialized. Authorize inputs and minimize returned data. |
| “RSC removes waterfalls.” | It removes some client round trips and colocates reads, but sequential server awaits can still waterfall. Start independent reads in parallel and stream useful boundaries. |
Scenario: A product route fetches from a database, parses Markdown, formats a localized price, renders an image gallery with swipe state, and includes an optimistic add-to-cart control. Where should the client boundary start?
Choose first. Then name the server-only imports, serialized props, browser capabilities, and transitive modules on each side.
“RSC and SSR solve different problems. RSC partitions execution and defines a serialized component payload; SSR turns the initial combined tree into HTML. I can use RSC at build time or request time, with or without streaming and caching.”
“I’d keep the route, database query, Markdown parser, and price formatter in the server graph. Gallery and cart are separate client entry points because they need browser state and events. I’d pass narrow serializable props rather than the entire ORM object.”
“I’d inspect the client module graph, RSC payload size, serialization cost, server render latency, data-fetch parallelism, hydration work, cache behavior, and navigation traces. A smaller client bundle can still be offset by slow or over-dynamic server work.”
'use client' — module graph boundaries, transitive dependencies, and supported serialized values.Answer before you reveal the explanation.
Quick recall
Say your answer first, then reveal the explanation.
HTML shows a quick, non-interactive version of the page. The RSC payload is compact data that describes the server-rendered component tree; React uses it to match the server and client trees. Client Component JavaScript then attaches event handlers and makes the interactive parts work; React calls this hydration.
Quick recall
Say your answer first, then reveal the explanation.
They run on the server, either during the build or while handling a request. They can fetch data and use server-only code, but they cannot use browser state, event handlers, or browser APIs.
Quick recall
Say your answer first, then reveal the explanation.
It marks that file as a boundary between server and client code. Components exported from it can run in the browser, so use it for parts that need state, event handlers, or browser APIs—not for every component.