12 middleware patterns: auth guards, i18n routing, A/B testing, rate limiting, geo-redirect, bot detection.
Uploaded markdown content, not a verification of tool compatibility or results. Review the raw text, commands, and permissions before using it. Stars require an account.
name: nextjs-middleware-recipes
Redirect unauthenticated users from protected routes.
Detect language from Accept-Language header.
Assign variant via cookie, rewrite to variant page.
Token bucket per IP using edge KV store.
Redirect based on Cloudflare geo headers.
Block bad bots, allow search engine crawlers.
Show maintenance page when env flag is set.