November 27, 2026 · 9 min read · Thomas Osayi
Next.js Server Actions not working? Causes and fixes for Next.js 16
Next.js Server Actions not working? Fix missing use server, client calls, stale pages after revalidateTag, the 1MB body limit, redirect in try/catch and auth checks.
Server Actions are one of the nicest parts of the Next.js App Router: write an async function, mark it as server only, pass it to a form, and the mutation, the cache update and the re-rendered page all come back in one request. They are also one of the places where AI-generated Next.js code breaks most quietly. The button does nothing, the form submits but the list does not change, or production throws an error that never appeared locally.
I checked everything below against the current Next.js documentation (the version 16 docs, which also call middleware Proxy now). I have grouped the fixes by symptom, because "not working" usually means one of five different things.
Is the 'use server' directive missing or in the wrong place?
If an action does nothing or throws an error about passing functions to client components, check that 'use server' is the very first line of the actions file, or the first line inside the function body.
The Next.js docs describe two placements. At the top of a file, it marks every exported function in that file as a Server Function. Inline, at the top of an async function, it marks just that function. It has to be the first statement. An import above it, or the directive written after a comment block that contains code, means the compiler does not treat the file as server code.
Things AI tools get wrong here:
- Putting 'use server' in a file that also exports constants, types or non-async helpers. Keep the actions file to async functions only.
- Writing 'use client' and 'use server' in the same file.
- Defining an inline action with 'use server' inside a component file that starts with 'use client'. That is not allowed. The inline form only works inside server components.
- Assuming 'use server' makes a file private. It does the opposite. It creates an endpoint the browser can call.
A quick test is to add a console.log as the first line of the action. If the log appears in your terminal, not the browser console, the action is running on the server and the problem is further along.
Am I calling the action from a client component correctly?
A client component must import the action from a separate file that starts with 'use server', then call it through a form action, a button formAction, or inside startTransition from an event handler.
The Next.js docs say that to use Server Functions in client components, you create them in a dedicated file with the directive at the top, and import them. The alternative is a server component that defines the action and passes it down as a prop.
How you invoke it matters too. A form with action set to the function is the simplest, and works even before JavaScript loads. From an onClick handler, wrap the call in startTransition (or use useActionState) so React tracks the pending state and applies the returned UI.
Two more client side traps:
- Next.js dispatches Server Actions one at a time per client. The docs warn not to rely on Promise.all to run several actions in parallel from the browser. If you need parallel work, do it inside one action.
- Arguments must be serializable. Passing a class instance, a function or a DOM event to an action fails. Pass plain values or FormData.
If your AI tool generated a fetch call to an API route next to a Server Action that does the same thing, pick one. Two paths for the same mutation is how bugs hide.
Why does the page not update after the action runs?
Because the action changed the data but did not tell Next.js which cached data or route to refresh, or it used revalidateTag in a way that deliberately does not re-render right away.
The Server Actions guide is precise here. The response includes a fresh render of the current route when the action calls updateTag, revalidatePath, refresh, sets or deletes a cookie, calls redirect, or calls revalidateTag with a profile that expires immediately. An action that does none of these returns only its value, and the current route is not re-rendered.
The catch that trips people up is revalidateTag. In Next.js 16, revalidateTag takes a cache life profile such as 'max'. With a stale-while-revalidate profile, it marks the tag for a background refresh. Subsequent reads get the stale value while fresh data loads, and the action response does not include a re-render. Your data did save. The user just does not see it until a later read.
Which one should I use?
- updateTag: the user needs to see their own change immediately (read your own writes). Server Actions only.
- revalidatePath: one route is affected and tags are overkill.
- revalidateTag with a profile: background freshness for content other people will see later.
- refresh: the page depends on state outside the cache, and you just changed it.
If an AI tool upgraded you from an older Next.js version, check for revalidateTag calls with a single argument. That older pattern does not express the same behavior under the new API.
Why do I get "Body exceeded 1mb limit"?
Server Action requests are capped at 1MB by default, so a form that sends a photo, a PDF or a large JSON payload fails before your code runs.
The Next.js docs list this as one of the framework protections: action requests are capped at 1MB by default, configurable with experimental.serverActions.bodySizeLimit in next.config.js. Their example raises it to 2mb. The configuration API under experimental.serverActions is still marked experimental, even though Server Actions themselves have been stable since Next.js 14.
Raising the limit is fine for modest uploads, like a profile photo resized in the browser first. For anything larger, I do not push files through a Server Action at all. The pattern I use is to upload the file straight from the browser to storage (Supabase Storage, Firebase Storage or S3) with a signed or rule-protected upload, then call the action with only the resulting file path. That keeps the action small and fast, and it avoids hitting your host's own request size limits on top of the Next.js one. If uploads are failing on Supabase in particular, "Supabase storage upload not working? Fix RLS, bucket, size and file type errors" covers the storage side.
Why does redirect not work inside my try/catch?
Because redirect works by throwing a special NEXT_REDIRECT error, and a catch block that catches everything swallows it, so the redirect never happens.
The redirect reference says it plainly: in Server Actions and Route Handlers, redirect should be called outside the try block when using try/catch. AI generated actions very often wrap the whole function body in try/catch, with a redirect at the end of the try, and a catch that returns an error message. The result is a form that saves the data, shows "Something went wrong", and stays on the same page.
The fix is structural:
- Do the work that can fail inside try.
- Return an error state from catch.
- Call redirect after the try/catch block, once you know it succeeded.
Order matters too. The Server Actions guide notes that because redirect throws, any code after it does not run. Put revalidatePath or updateTag before redirect if the destination needs fresh data.
A related symptom is a redirect that goes to the right page but shows stale data, which is exactly that ordering problem. If the redirect bounces back and forth, the cause is more likely a Proxy or auth rule, and "Too many redirects in Next.js (ERR_TOO_MANY_REDIRECTS): find the loop and fix it" is the better guide.
Are environment variables or auth checks failing inside the action?
Often, yes: the action runs on the server, so it needs server side environment variables to exist in your host, and it needs to read the user's session from cookies itself.
Environment variables first. Actions can read secrets like DATABASE_URL or STRIPE_SECRET_KEY, which is the point. But if the variable is only in your local .env file and not in the hosting provider's settings for that environment, the action fails in production with an undefined value. A variable prefixed NEXT_PUBLIC_ is inlined at build time, so changing it requires a rebuild. "Environment variables undefined on Vercel? Every cause and fix" goes through each case.
Auth second. The Next.js docs are emphatic that every Server Action should be treated as an untrusted entry point. It runs as a POST request, and anyone who can send that POST can call it. Hiding the form on a logged in page is not a security boundary. Inside each action:
- Read the session from cookies or headers, not from an argument the client passes.
- Check the user owns the record they are changing, by querying with both the record ID and the user ID.
- Validate inputs, and return only what the UI needs.
AI tools often generate actions that accept a whole object from the client, including its ID and owner. That is the unsafe pattern the docs warn about.
What does "Failed to find Server Action" mean in production?
It means a browser running an older build called an action ID that the newest deployment no longer recognizes, which happens right after you deploy.
The docs explain that each action is identified by an ID that is part of the build, and new deployments typically generate new IDs (Next.js rotates them at most every 14 days even if the code does not change). A user who loaded the page before your deploy and submits a form after it sends the old ID.
What helps:
- Show a friendly retry message when an action fails, so a refresh recovers the user.
- On self hosted or multi instance setups, set NEXT_SERVER_ACTIONS_ENCRYPTION_KEY to a stable value shared across instances, as the docs recommend.
- Avoid deploying in the middle of heavy use if your host does not offer skew protection.
If you see this error constantly, not just after deploys, something else is wrong, such as two different builds being served at once.
How do I debug a Server Action step by step?
Confirm the action runs, confirm the data changed, then confirm the page was told to refresh, in that order.
Here is an illustration with a made-up app. A tutoring studio's booking dashboard, built in v0 and finished in Cursor, had a "Mark lesson complete" button that did nothing visible. A log at the top of the action showed it ran. The database showed the row did update. The action called revalidateTag('lessons', 'max'), which is a background refresh, so the page kept showing the old status until a later visit. Switching to updateTag('lessons') fixed the display. While in there, I also noticed the action accepted a lessonId with no ownership check, so any signed in tutor could mark any lesson complete. Adding a session lookup and a where clause on both the lesson and the tutor closed that.
That sequence (runs, saves, refreshes, secured) catches nearly every case. One broken action like this is a Quick Fix from $60 with about 2 days of turnaround. Several broken forms plus an auth pass across all actions fits Fix Plus Features from $200 over about 5 days.
The bottom line
When Next.js Server Actions are not working, the symptom tells you where to look. Nothing happens: check 'use server' placement and how the client calls the action. Data saves but the page is stale: use updateTag, revalidatePath or refresh rather than a stale-while-revalidate revalidateTag. Large forms fail: you hit the 1MB default body limit. The redirect never fires: move redirect out of the try block. Production only failures: check server environment variables and stale action IDs after a deploy.
And whatever the symptom, check auth inside every action. A Server Action is a public endpoint with a friendly syntax, and the framework cannot know who is allowed to change what.
Questions, answered in one line
Why does my Server Action run but the page does not update?
The action probably did not invalidate the cached data the page reads, or it used revalidateTag with a stale-while-revalidate profile, so call updateTag, revalidatePath or refresh after the mutation.
What does "Failed to find Server Action" mean?
It usually means a browser still running an older deployment called an action ID that the new deployment no longer has, and a page refresh fixes it for that user.
Can I define a Server Action inside a client component?
No, a client component has to import the action from a separate file that starts with 'use server', or receive it as a prop from a server component.
How do I upload files larger than 1MB with a Server Action?
Raise experimental.serverActions.bodySizeLimit in next.config.js for moderate sizes, or upload large files directly from the browser to storage with a signed URL and send only the file path to the action.
Can Thomas Osayi fix broken Server Actions in my AI-built Next.js app?
Yes, one broken action is a Quick Fix from $60 with about 2 days of turnaround, and several broken forms plus an auth review fits Fix Plus Features from $200.
Sources
- Server Actions and Mutations Next.js
- use server directive Next.js
- redirect Next.js
Related articles
- Supabase auth redirect URL not working? Fix localhost, preview and production redirects
- Environment variables undefined on Vercel? Every cause and fix
- How to fix a CORS error on a Next.js API route
- Firestore "Missing or insufficient permissions": what triggers it and how to fix it
Fix, finish and launch your AI-built app
Built your app with Lovable, Bolt, v0, Replit or Cursor and got stuck? I fix the bugs, connect auth and payments, clean up the code and deploy it to production.
See the service