routing-middleware

Configure Vercel Routing Middleware for request interception, rewrites, redirects, and geo-personalization.

Updated Jul 31, 2026
One-click install
npx skills add https://github.com/AarnavBaddam/skills --skill routing-middleware-aarnavbaddam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: routing-middleware
Source: https://github.com/AarnavBaddam/skills/tree/main/routing-middleware
Command: npx skills add https://github.com/AarnavBaddam/skills --skill routing-middleware-aarnavbaddam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @vercel/functions, @vercel/edge-config, @vercel/config.

What problem does it solve? Intercepting requests at the platform level before the cache is confusing because Vercel has three overlapping "middleware" concepts, and choosing the wrong one leads to runtime errors, deprecated patterns, or security gaps like the CVE-2025-29927 auth bypass. ## Core Features & Use Cases - Middleware Disambiguation: Clarifies the differences between Vercel Routing Middleware (middleware.ts), Next.js 16 Proxy (proxy.ts), and Edge Functions so you pick the right interception layer. - Request Interception Patterns: Provides working examples for geo-personalization, A/B testing with Edge Config, header injection, IP detection, and background processing with waitUntil. - Runtime & Routing Configuration: Covers Edge, Node.js, and Bun runtimes, matcher scoping, project-level routes without redeploys, and programmatic config via vercel.ts and @vercel/config. - Use Case: You want to serve a different homepage variant to US visitors without redeploying. Use this Skill to write a middleware.ts that reads geolocation and rewrites the URL before the cache. ## Quick Start Write a Vercel routing middleware that redirects users based on their country using geolocation.

Frequently Asked Questions about routing-middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create Vercel routing middleware for rewrites and redirects?

Create a middleware.ts file at the project root with a default exported function that returns rewrite() or next() from @vercel/functions. Scope it with config.matcher so it only runs on matching paths, and choose the edge or nodejs runtime.

What is the difference between middleware.ts and proxy.ts in Next.js 16?

middleware.ts is Vercel Routing Middleware running on Edge, Node, or Bun for any framework, while proxy.ts is Next.js 16's Node.js-only network-boundary layer. Next.js 16 deprecates middleware.ts and provides a codemod: npx @next/codemod@latest middleware-to-proxy.

Does Vercel middleware support the Bun runtime?

Yes, add bunVersion to vercel.json and set the middleware runtime to nodejs; Bun transparently replaces the Node.js runtime. It is in Public Beta and supports Next.js, Express, Hono, and Nitro.

How do I run middleware only on specific routes?

Use the config.matcher export with path patterns like '/dashboard/:path*' or regex to exclude static files. Unmatched paths skip middleware invocation entirely, which saves compute.

When should I not use Vercel routing middleware?

Avoid it for heavy business logic, database queries, or as your sole auth layer. Use proxy.ts for full Node.js APIs in Next.js, Edge Functions for general edge compute, and Bulk Redirects for thousands of static redirects.