routing-middleware

Configure Vercel middleware for routing, personalization, and security before cache hits.

246|42|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/vercel-labs/vercel-plugin --skill routing-middleware
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: routing-middleware
Source: https://github.com/vercel-labs/vercel-plugin/tree/main/skills/routing-middleware
Command: npx skills add https://github.com/vercel-labs/vercel-plugin --skill routing-middleware

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you manage and intercept incoming requests at the Vercel platform level, allowing for dynamic routing, personalization, and security checks before content is served from the cache.

Core Features & Use Cases

  • Request Interception: Run code before the cache to modify requests or responses.
  • Dynamic Routing: Implement rewrites, redirects, and header injections based on request properties like geolocation or cookies.
  • Personalization & A/B Testing: Serve different content variations to users based on custom logic.
  • Use Case: Automatically redirect users from specific countries to localized landing pages or inject security headers like Content-Security-Policy on all incoming requests.

Quick Start

Use the routing-middleware skill to configure a rewrite rule for '/old-page' to '/new-page'.

Frequently Asked Questions about routing-middleware

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

FAQPage Schema
How does Vercel middleware intercept requests before cache hits?

Vercel middleware intercepts incoming requests at the platform level before cache hits, allowing you to run custom code for dynamic routing, personalization, and security checks before content is served.

How do I set up redirects and rewrites using Vercel edge functions?

You can configure redirects and rewrites programmatically via `vercel.ts`, using helper functions and matcher configurations to dynamically route traffic based on request properties like geolocation or cookies.

Can I run A/B testing and personalization logic on the Vercel platform?

Yes, you can run A/B testing and personalization on the Vercel platform by executing custom logic within the middleware layer, serving different content variations to users using Edge Config.

What runtime options are supported for Vercel routing middleware?

Vercel routing middleware supports multiple runtime options including Edge, Node.js, and Bun, allowing you to choose the execution environment that best fits your request interception and performance needs.

How do I inject security headers into all incoming requests on Vercel?

You inject security headers by defining custom logic in Vercel middleware that modifies response headers, allowing you to apply configurations like `Content-Security-Policy` globally before requests reach the cache.