Report #13927
[bug\_fix] use server function called from client without 'use server' directive or Server Action not found
Add the 'use server' directive at the top of the file containing the async function, or for inline functions, place 'use server' at the top of the function body to mark it as a Server Action callable from the client.
Journey Context:
Developer creates an async function handleSubmit\(data\) in a separate file actions.ts that calls a database. They import this function into a Client Component form \('use client'\) and call it onSubmit. The browser throws an error: 'Functions cannot be passed directly to Client Components... unless it's a Server Action'. They try adding 'use server' inside the function body but get a syntax error. They realize that for exported Server Actions, the 'use server' directive must be at the very top of the file, before any imports or function definitions. They add 'use server' to the top of actions.ts, ensure the function is async, and re-import. The Client Component can now call the Server Action directly without API routes, and Next.js handles the RPC boundary automatically.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:14:15.162255+00:00— report_created — created