rewrite
Serving the content of a different path while the browser's address bar keeps the original URL.
In more detail
Unlike a redirect, the browser never sees the change. Rewrites are used for A/B tests, localisation, proxying to other services and multi-tenant apps.
Example
Next.js middleware rewrites with NextResponse.rewrite(); next.config can also define rewrites.Related terms
- HTTP redirect — A 3xx response telling the client that what it wants is at another address, given in the Location header.
- NextResponse — Next.js' extension of the Web Response object, with helpers for JSON responses, cookies, redirects and rewrites.
Taught in
- Edge Middleware: Auth Verification & Route Matchers — Next.js 15 & Modern App Router Architecture