Next.js · sdk · fg-0310
redirect() in a Server Action does nothing, or logs NEXT_REDIRECT, when it sits inside try/catch
Error: NEXT_REDIRECT
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
redirect(), permanentRedirect() and notFound() work by throwing a special error that the framework catches higher up. A surrounding try/catch intercepts it first, so the navigation never happens.
Fix
Call redirect() after the try/catch block, or rethrow framework errors at the top of the catch with unstable_rethrow.
Apply
import { redirect, unstable_rethrow } from 'next/navigation'
try {
await save(data)
} catch (err) {
unstable_rethrow(err)
return { error: 'Save failed' }
}
redirect('/done')Affects: Next.js App Router 13.4 to 16.4, Server Actions, Route Handlers and Server Components
Sources
- https://nextjs.org/docs/app/api-reference/functions/redirect
- https://nextjs.org/docs/app/api-reference/functions/unstable_rethrow
- https://github.com/vercel/next.js/issues/55586
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp