Skip to main content
Next.js & React · Developer Error Resolution Lab

Fix Next.js Error: 'Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with use server'

Resolve React Server Component serialization errors when passing callbacks or non-serializable classes across the Server-Client boundary.

Triggered Error Message:

Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".

Customize Solution for Your Environment
// actions.ts
"use server";

export async function submitFormAction(formData: FormData) {
  // Server-side logic here
  return { ok: true };
}

Root Cause & Mechanism Analysis

Why does this error occur?

Props passed from a Server Component to a `"use client"` component must be serialized over the React Flight wire format. Regular JavaScript closures cannot be serialized across the network unless marked as a Server Action (`"use server"`).

Frequently Asked Questions

Can I pass Date or Map objects from Server to Client Components?
Plain objects, arrays, strings, numbers, booleans, and `Date` instances are supported by React Flight, or convert timestamps to ISO strings / epoch numbers using `npx castov time now`.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 54 Guides