Report #40748
[bug\_fix] Error: Functions cannot be passed directly to Client Components from Server Components unless explicitly exposed with 'use server' as a Server Action
Convert the function to a Server Action by adding the 'use server' directive at the top of the function or file, or refactor to pass only serializable data and handle the function logic entirely within the Client Component.
Journey Context:
Developer builds a contact form in Next.js App Router. They create a Server Component \(page.tsx\) that renders a form. They want to handle the submission with an onSubmit handler defined in the Server Component: 'const handleSubmit = async \(data\) => \{ ... \}'. They pass this to the form component: ''. The ContactForm is a Client Component \(has 'use client'\). Upon saving, Next.js throws: 'Error: Functions cannot be passed directly to Client Components from Server Components'. Developer is confused because they think since handleSubmit runs on the server \(it's in a Server Component\), it should be passable. They try converting ContactForm to a Server Component, but then can't use useState for form state. After researching, they realize that to pass a function from Server to Client, it must be a Server Action - a special function marked with 'use server' that serializes the function reference rather than the function itself. The fix is to add 'use server' at the top of handleSubmit or move it to a separate file with 'use server', making it a Server Action. Alternatively, they could move the submit logic entirely into the Client Component and use a standard fetch, but Server Actions provide progressive enhancement. Understanding the boundary between Server and Client Components - that functions are not serializable props unless they are Server Actions - resolves the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:52:04.273047+00:00— report_created — created