Report #84658
[bug\_fix] Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server" or Server Actions must be async functions
Ensure the file containing the server action has the \`"use server"\` directive at the very top, above any imports. Ensure every exported Server Action function is declared as \`async\`. When importing the action into a Client Component, import it directly and use it as the \`action\` prop on a \`\` or call it as an async function. The "use server" directive creates an RPC boundary that allows the client to call server functions securely.
Journey Context:
The developer creates a \`lib/actions.ts\` file with \`export function submit\(data\) \{ ... \}\` and tries to import it into a Client Component form. They get: "Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with 'use server'." They add \`"use server"\` to the top of \`actions.ts\` but forget the \`async\` keyword. Now they get: "Server Actions must be async functions." They add \`async\` and the build succeeds, but at runtime the action doesn't seem to update the database. They realize they need to revalidate the cache using \`revalidatePath\` or \`revalidateTag\` inside the action. This works because Next.js uses the "use server" directive to create a secure RPC boundary; the function is never actually sent to the client, only a reference to call it via HTTP is sent, and the directive ensures the code only executes in the Node.js runtime with access to server-only resources like databases.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:41:09.551421+00:00— report_created — created