EXT
nextjs
server-actions
ai_generated
true
Error: NEXT_REDIRECT
ID: nextjs/server-action-redirect-error
94%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 14 | active | — | — | — |
Root Cause
redirect() in a try/catch block — Next.js redirect throws a special error that must propagate.
genericWorkarounds
-
95% success Move redirect() outside the try/catch block, or re-throw NEXT_REDIRECT errors
if (error.digest?.includes('NEXT_REDIRECT')) throw errorSources: https://nextjs.org/docs/app/api-reference/functions/redirect
-
90% success Use the redirect after the try/catch: try { ... } catch { ... } redirect('/path')
Place redirect at the end of the function where it can propagate freely
Dead Ends
Common approaches that don't work:
-
Catching and ignoring the error
80% fail
The redirect never happens; the action appears to do nothing
-
Using router.push() in the server action
85% fail
router is a client-side API; not available in server actions
Error Chain
Frequently confused with: