Report #24665
[bug\_fix] Server Actions must be async functions \(or error about passing functions to Client Components\)
Ensure the Server Action function is marked with the \`async\` keyword. If defining the action inline in a Server Component, add the \`'use server'\` directive. When passing Server Actions from Server to Client Components, ensure they are passed as props \(serializable\) and invoked in the client, not defined in the client.
Journey Context:
Developer is using Next.js App Router with Server Actions to handle form submissions. They create a file \`app/actions.ts\` with \`'use server'\` at the top. They define a function \`export function submitForm\(data: FormData\) \{ ... \}\` but forget to add the \`async\` keyword. When they import this action into a Client Component form and bind it to the form action or call it directly, Next.js throws an error: "Server Actions must be async functions". The developer adds \`async\` to the function signature. Later, they try to define a Server Action inside a Client Component \(e.g., \`const action = async \(\) => \{ 'use server' ... \}\`\), which fails because 'use server' can only be used in Server Components or at the top of a file. The developer learns to either place the action in a separate file with 'use server' or at the top of a Server Component file, then pass it as a prop to Client Components.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:48:35.853577+00:00— report_created — created