Course contentsShow
← React
Lesson 1531 of 2,39638. Server Components FundamentalsFree lesson

Server Components Compose with Client Components

Server Components can render Client Components as children, passing serializable props across the boundary.

Server Components Compose with Client Components

What you'll learn: How Server Components can safely render Client Components as children while respecting the server/client boundary.

The Composition Pattern

One of the most powerful aspects of React Server Components is that Server Components can render Client Components. This composition works seamlessly because React treats the client/server boundary as a clear line: Server Components execute on the server and pass serializable data (props) across to Client Components that hydrate on the client.

Think of it like a restaurant kitchen (server) preparing ingredients that get delivered to your table (client). The kitchen doesn't need to know what you'll do with your food—it just prepares it and sends it out. Similarly, Server Components don't need to know about the interactive behavior inside Client Components.

How It Works

When a Server Component renders a Client Component, it passes props across the boundary. These props must be serializable—JSON-friendly values like strings, numbers, objects, and arrays. React sends the RSC wire format to the browser, which includes instructions like "render this Client Component here with these props."

The Server Component can fetch data, perform heavy computation, or import server-only code, then pass the results as props to Client Components. The Client Component then hydrates on the client with those props and adds interactivity.

The Mental Model

Server Components act as the outer shell or layout, deciding what to render and where. Client Components handle how users interact with that content. This composition pattern means you can wrap interactive islands (Client Components) with server-rendered structure (Server Components) efficiently.

Key Takeaway: Server Components can render Client Components as children, passing serializable props across the boundary—enabling powerful composition where server logic prepares data and client components handle interactivity.