What problem does it solve?
This Skill helps you design correct Next.js middleware by clarifying what belongs in middleware and how to implement common cross-cutting behaviors without breaking Edge constraints or hurting performance.
Core Features & Use Cases
- Middleware-first cross-cutting design: Apply shared request pre-processing across many routes using matcher-scoped logic, not per-route handlers.
- Routing transformations: Use pass-through, rewrite, redirect, and direct responses to implement auth gates, locale routing, A/B rewrites, and geo routing.
- Edge-compatible delivery patterns: Follow Edge Runtime constraints and implement request correlation (request-id) and security-header delivery (including per-request CSP nonces).
- Performance and correctness discipline: Prevent common footguns like running on static assets unintentionally, doing database lookups in middleware, or importing Node-only libraries.
Quick Start
Use this skill to review or draft a Next.js middleware.ts that authenticates protected routes, redirects unauthenticated users to login, rewrites locale variants, injects a per-request CSP nonce, and excludes static assets via config.matcher.