Next.js Redirecting
Installation
SKILL.md
Next.js Redirecting
Expert guidance on handling redirects in Next.js — redirect, permanentRedirect, useRouter, next.config.js redirects, Proxy, and managing redirects at scale.
@doc-version: 16.2.6
Core Concepts
| API | Purpose | Where | Status Code |
|---|---|---|---|
redirect |
After mutation/event | Server Components, Server Actions, Route Handlers | 307 / 303 |
permanentRedirect |
After mutation (permanent) | Server Components, Server Actions, Route Handlers | 308 |
useRouter |
Client-side navigation | Event Handlers in Client Components | N/A |
redirects in next.config |
Path-based redirects | Config file | 307 / 308 |
NextResponse.redirect |
Conditional redirects | Proxy | Any |
Execution order: next.config.js redirects → Proxy → rendering