# Error: Server Action redirected but the page was not revalidated. Use revalidatePath or revalidateTag before redirect to ensure fresh data.

- **ID:** `nextjs/server-action-redirect-without-revalidate`
- **Domain:** nextjs
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

A Server Action calls redirect() after mutating data without calling revalidatePath() or revalidateTag() first. Next.js requires explicit cache revalidation before redirects in Server Actions to prevent stale data from being displayed.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Next.js 14.x | active | — | — |
| Next.js 15.x | active | — | — |

## Workarounds

1. **Call revalidatePath() before redirect() in your Server Action. Example: 'use server'; import { revalidatePath } from 'next/cache'; import { redirect } from 'next/navigation'; export async function updateData(formData) { // mutate data revalidatePath('/dashboard'); redirect('/dashboard'); }** (88% success)
   ```
   Call revalidatePath() before redirect() in your Server Action. Example: 'use server'; import { revalidatePath } from 'next/cache'; import { redirect } from 'next/navigation'; export async function updateData(formData) { // mutate data revalidatePath('/dashboard'); redirect('/dashboard'); }
   ```
2. **Use revalidateTag() if you have tagged your fetch calls. Example: revalidateTag('posts'); redirect('/posts');** (85% success)
   ```
   Use revalidateTag() if you have tagged your fetch calls. Example: revalidateTag('posts'); redirect('/posts');
   ```
3. **If you do not want to redirect, return a success response instead and let the client handle navigation with router.push() after the Server Action completes.** (75% success)
   ```
   If you do not want to redirect, return a success response instead and let the client handle navigation with router.push() after the Server Action completes.
   ```

## Dead Ends

- **** — redirect() throws a NEXT_REDIRECT error that stops execution. Any code after redirect() will never run. revalidation must happen before the redirect call. (100% fail)
- **** — router.refresh() is a client-side method and cannot be called inside a Server Action. It also does not affect server-side cache invalidation. (95% fail)
- **** — This prevents caching but does not revalidate the specific path after mutation. The redirect will still work, but Next.js will still warn about missing revalidation, and the behavior is not guaranteed in future versions. (60% fail)
