Report #91788
[bug\_fix] Error: Functions cannot be passed directly to Client Components because they are not serializable. Only plain objects, and a few built-ins, can be passed to Client Components.
Move the function definition inside the Client Component file instead of passing it as a prop from a Server Component. Alternatively, if the function needs to run on the server but be triggered from the client, convert it to a Server Action by adding the 'use server' directive \(making it an async function that can be passed to the client\). If the function is an event handler, define it inside the Client Component rather than passing it from the parent Server Component. The root cause is the Server/Client boundary in React Server Components requires all props to be serializable \(JSON-like\) to cross from server to browser; functions and class instances cannot be serialized.
Journey Context:
Developer has a Server Component \(app/page.tsx\) that fetches a list of products. They want to add an 'Add to Cart' button that calls a function handleAddToCart when clicked. They define handleAddToCart in the Server Component and try to pass it as a prop to a Client Component \(ProductCard\): . Immediately, they get the error that functions cannot be passed to Client Components. They try to make the parent a Client Component with 'use client', but then they lose the ability to fetch data efficiently on the server. They consider using context, but that requires the parent to be a Client Component too. Eventually, they realize they should either move the onAdd logic inside ProductCard \(if it doesn't need server data\), or convert handleAddToCart to a Server Action with 'use server', or pass minimal data and reconstruct the handler inside the Client Component using useCallback.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:39:32.962129+00:00— report_created — created