Report #96602
[bug\_fix] Server Action cannot be called from Client Component directly
Define the Server Action in a separate file with 'use server' at the top, then import it into the Client Component. Or, pass the action as a prop from a Server Component. Root cause: Server Actions marked with 'use server' create a RPC boundary. Client Components cannot define Server Actions inline; they must import them from server files.
Journey Context:
Developer creates a form in a Client Component \('use client'\) with an onSubmit that calls a database mutation. Writes the async function directly in the Client Component: \`async function createUser\(\) \{ 'use server'; ... \}\`. Gets error that Server Actions cannot be called from Client Components. Developer moves the function to a separate file \`actions.ts\` with 'use server' at the top, then imports it into the Client Component. Error resolved. Alternatively, developer could have kept the Client Component as a child of a Server Component, passing the action as a prop.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:43:50.557220+00:00— report_created — created