matcher (middleware)

The config.matcher option exported from middleware.ts that lists which paths the middleware runs on.

In more detail

Entries are path patterns such as /admin/:path* or regular expressions, for example one that excludes _next/static, images and favicon.ico. Values must be constants so Next.js can read them at build time.

Example

export const config = { matcher: ['/admin/:path*'] };

Related terms

Taught in

References