Next.js: Error: Server actions must be async functions
A function marked "use server" isn't declared async.
Server actions must be async functionsError: Only async functions are allowed to be exported in a "use server" fileA "use server" file can only export async functions, found objectServer Actions must be async functions Meaning
Server Actions are invoked over the network and must return a Promise. Add async to every exported function in a "use server" file. In files with "use server" only async function exports are allowed (constants/types can't be exported).
Common causes
- Missing
asynckeyword - Exporting a non-function value from a "use server" file
- Arrow function exported without async
- Inline action without async
- Re-exporting synchronous helpers
⚡ Quick fix
export async function save(formData: FormData) {}- Keep non-async helpers in a separate file without "use server"
- Move constants to another module
Detailed fix by platform
Next.js
- tsx
"use server"; export async function createPost(formData: FormData) { /* ... */ }
How to diagnose
- Keyword — async?
- Exports — Only async functions?
- Helpers — Separate file?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Body exceeded 1 MB limit (Server Actions) Next.js: Error: Body exceeded 1 MB limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- CORS error calling Next.js API route / route handler Browser: Access to fetch at 'https://api.example.com/api/data' from origin 'https://app.example.com' has been blocked by CORS policy (Next.js route handler)
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026