Functions Cannot Be Serialized
What you'll learn: Why you can't pass functions, class instances, or closures from server components to client components as props.
When React sends data from server components to client components, it has to serialize that data—convert it into a format that can be transmitted over the network. Functions, however, cannot be serialized.
Think of serialization like packing a suitcase for a flight. You can pack clothes (strings), books (numbers), and photos (objects with plain data). But you can't pack a live conversation or a personal relationship—those only exist in the moment and context where they started. Functions are like that: they carry logic and often reference variables from their surrounding scope (closures), which can't be captured in a text format and sent across the wire.
Why This Matters
Server components run on the server once. Any function you define there exists only during that server execution. By the time the client component receives props, the server execution is complete—those functions no longer exist anywhere.
This means you cannot do this:
// ❌ Server Component - INVALID
async function ServerParent() {
const handleClick = () => console.log('clicked');
return <ClientButton onClick={handleClick} />;
}
The handleClick function cannot cross the boundary. Same goes for class instances or any closure that references server-side variables.
What You Can Pass
You've learned that strings, numbers, plain objects, arrays, and React elements can cross the boundary. If you need interactivity, define the function in the client component itself, or use Server Actions for server-side mutations.
Key Takeaway: Functions, class instances, and closures cannot be serialized and passed from server to client components—only plain, JSON-serializable data and React elements can cross the boundary.