Composing Server and Client: Passing RSC as Props
You'll learn how to keep more of your component tree on the server by passing Server Components through Client Component boundaries as props.
The Composition Pattern
When you need a Client Component for interactivity, you might assume everything inside it must become client-side too. But React Server Components support a powerful pattern: you can pass Server Components as props (including children) to Client Components.
This works because React doesn't care what you pass—it only cares that the Client Component receives already-rendered React elements. The Server Component has already executed on the server and produced its output before the Client Component ever sees it.
Why This Matters
Imagine a modal dialog (which needs 'use client' for open/close state). If you render Server Components directly inside the modal's JSX, they become client components. But if you pass the modal's content as a prop, that content stays on the server:
// ❌ Forces everything inside to be client-side
<ClientModal>
<ServerHeavyContent /> {/* Now client! */}
</ClientModal>
// ✅ Keeps content on the server
<ClientModal content={<ServerHeavyContent />} />
// or using children:
<ClientModal>
<ServerHeavyContent /> {/* Still server! */}
</ClientModal>
The second pattern works because you're passing the result of rendering ServerHeavyContent through the boundary, not importing and rendering it inside the Client Component.
The Analogy
Think of it like a picture frame (Client Component) that can display any photo (Server Component). The frame doesn't care what the photo is—it just positions it. The photo was developed elsewhere.
Key Takeaway: Pass Server Components as children or props to Client Components to keep expensive rendering and data fetching on the server while still composing interactive UI.