DEV Community
•
2026-07-26 21:03
Next.js Middleware in 2026: Auth Guards, A/B Tests, and What Belongs at the Edge
Headline: Next.js Middleware (middleware.ts at the project root) runs before every matched request — before cache, before rendering, before the route. That position makes it right for auth redirects, A/B cookie bucketing, and locale detection. Wrong for database queries and heavy imports. In 2026, Middleware on Vercel runs on Fluid Compute (standard Node.js), so the constraint is latency budget, ...