Passing Server Components as Props to Client Components
What you'll learn: How to compose Server Components inside Client Components using the children prop pattern without breaking React's Server/Client boundary rules.
The Problem This Solves
You've learned that Server Components cannot directly import Client Components that contain Server Components. But what if you want a Client Component wrapper (like a collapsible section or tabs) that contains Server Component content?
The Children Prop Escape Hatch
Here's the key insight: Server Components can be passed as props to Client Components. The most common pattern uses the children prop:
// ServerParent.jsx (Server Component - no directive)
import ClientWrapper from './ClientWrapper'
import ServerChild from './ServerChild'
export default function ServerParent() {
return (
<ClientWrapper>
<ServerChild /> {/* Server Component passed as children */}
</ClientWrapper>
)
}
// ClientWrapper.jsx
'use client'
export default function ClientWrapper({ children }) {
const [isOpen, setIsOpen] = useState(true)
return (
<div>
<button onClick={() => setIsOpen(!isOpen)}>Toggle</button>
{isOpen && children}
</div>
)
}
Why This Works
The Client Component doesn't import the Server Component—it just receives a rendered slot. Think of children as a hole in the Client Component that the Server Component fills from the outside. The Server Component tree stays on the server; the Client Component just positions it.
This works with any prop name, not just children: header={<ServerNav />} or sidebar={<ServerMenu />} follow the same pattern.
Key Takeaway: Use the children prop (or any prop) to pass Server Components into Client Components—the parent Server Component does the composition, keeping the boundary clean.