routing-middleware

Routes, rewrites, and redirects requests at the Vercel platform layer via middleware.ts/js.

Updated May 16, 2026
One-click install
npx skills add https://github.com/MohammedHTahir/vibe-coding-platform --skill routing-middleware-mohammedhtahir
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: routing-middleware
Source: https://github.com/MohammedHTahir/vibe-coding-platform/tree/main/.kiro/vercel-plugin/skills/routing-middleware
Command: npx skills add https://github.com/MohammedHTahir/vibe-coding-platform --skill routing-middleware-mohammedhtahir

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Routing middleware removes the need for redeploying your app just to adjust request routing rules, headers, or redirects, by handling them before caching at the platform level.

Core Features & Use Cases

  • Request interception before cache: Apply rewrites, redirects, and lightweight per-request behavior at the CDN edge rather than inside your app runtime.
  • Framework-agnostic routing: Works across Next.js, SvelteKit, Astro, Nuxt, and other deployed frameworks using a consistent middleware entrypoint.
  • Targeted scope with matchers: Use matcher configuration to restrict execution to specific routes (e.g., /dashboard) and reduce unnecessary compute.
  • Personalization and A/B experimentation: Route requests based on geolocation or experiment assignment using platform-friendly primitives.

Quick Start

Add a root middleware.ts that exports a default function using Vercel Routing Middleware helpers, then set config.matcher to the paths you want to intercept.

Frequently Asked Questions about routing-middleware

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

FAQPage Schema
How do I set up edge redirects and rewrites without redeploying my application?

Edge redirects and rewrites can be handled by adding a root middleware.ts file with a default export function. This intercepts requests at the Vercel platform layer before caching, allowing routing changes without application code deployments.

Can I use routing middleware with frameworks other than Next.js?

Yes, routing middleware is framework-agnostic and works across Next.js, SvelteKit, Astro, and Nuxt. It uses a consistent middleware entrypoint to apply CDN routing rules universally across these deployed frameworks.

How do I restrict middleware execution to specific routes like /dashboard?

You can restrict middleware execution to specific routes by setting the config.matcher property in your middleware entrypoint. This targets scoped interception, reducing unnecessary compute for high-traffic routes before cache.

What is edge-level personalization and how does it work with Vercel Edge Config?

Edge-level personalization routes requests based on geolocation or experiment assignment using platform-friendly primitives. It intercepts requests at the CDN edge, applying header injection and targeted routing without touching app runtime logic.

Does Vercel routing middleware support Bun and Node runtimes?

Vercel routing middleware supports Edge, Node, and Bun runtimes. It requires a root middleware.ts or middleware.js entrypoint with default export semantics to function across these supported environments.

When should I use edge middleware instead of handling redirects in my application code?

Use edge middleware for CDN routing when you need to adjust request routing rules, headers, or redirects without redeploying app code. It applies lightweight per-request behavior at the platform level before caching for high-traffic routes.