redirects (next.config)

Declaratively redirects incoming requests to another path or URL.

Since Next 9.5+ Spec ↗

Syntax

async redirects() { return [{ source, destination, permanent }] }

Parameters

NameTypeRequiredDescription
redirects () => Promise<Redirect[]> No Each rule has `source`, `destination`, `permanent`, and optional `has`/`missing` conditions.

Returns

Promise<Redirect[]> — List of redirect rules applied before routing.

Examples

const nextConfig = {
  async redirects() {
    return [
      {
        source: '/old-blog/:slug',
        destination: '/blog/:slug',
        permanent: true,
      },
    ]
  },
}
module.exports = nextConfig
const nextConfig = {
  async redirects() {
    return [
      {
        source: '/dashboard',
        missing: [{ type: 'cookie', key: 'token' }],
        destination: '/login',
        permanent: false,
      },
    ]
  },
}
module.exports = nextConfig

Notes

`permanent: true` emits 308 (browsers/SEO cache it); `false` emits 307. Path params (`:slug`) and wildcards (`:path*`) carry over. `has`/`missing` add header/cookie/query conditions. For dynamic per-request logic prefer `middleware.js`. Runs before the filesystem routes.

See also