This guide shows you how to create redirects that update instantly without redeploying. Store redirect rules in Global Config and read them from your Next.js proxy.
Copy link to headingBefore you start
You'll need:
- A Next.js project deployed on Vercel
- A Vercel account (Global Config is available on all plans)
Copy link to headingStep 1: Create an Global Config
Go to your Vercel dashboard and navigate to Storage > Global Config > Create Global Config.
Name it something descriptive like redirects or routing-config.
After creation, you'll see your Global Config ID (starts with ecfg_). You'll need this later.
Reference: Global Config quickstart
Copy link to headingStep 2: Connect Global Config to your project
In your Global Config's settings, click Connect Project and select your Next.js project.
This automatically adds the GLOBAL_CONFIG environment variable to your project. The variable contains your connection string, which the SDK uses to read data.
For local development, pull the environment variable:
This downloads all your project's environment variables, including GLOBAL_CONFIG, into .env.local.
Copy link to headingStep 3: Add redirect rules to Global Config
In the Global Config dashboard, insert:
The structure is simple: an array of objects with source, destination, and permanent properties.
For now, use exact paths. The Advanced patterns section shows how to add support for wildcards, parameters, and regex matching (like /blog/:slug or /docs/:version/:path*).
Copy link to headingStep 4: Install the Global Config SDK
The SDK provides a get() function that reads data from your Global Config with ultra-low latency.
Reference: @vercel/global-config SDK
Copy link to headingStep 5: Create the middleware
Create a proxy.ts file in /src or the root of your project (if you don't have a /src directory):
What this does:
- Reads the
redirectsarray from Global Config on every request - Checks if the current URL path matches any source path (exact match only)
- If matched, redirects to the destination with the appropriate status code
- If anything fails, the request continues normally
This basic example uses exact path matching. See the Advanced patterns section to add support for wildcards (:slug*), parameters (:id), and regex patterns.
File naming: Use proxy.ts for Next.js 16+, or middleware.ts for Next.js 15 and earlier.
Reference: Next.js proxy
Copy link to headingStep 6: Deploy and test
Deploy your project:
Then test your redirects:
- Visit your old URL (e.g.,
https://your-site.vercel.app/old-blog) - You should be redirected to the new URL (
/blog) - Check the network tab: you'll see a 307 or 308 status code
Copy link to headingUpdating redirects without redeploying
This is where Global Config shines. To add, modify, or remove redirects:
- Go to your Global Config in the Vercel dashboard
- Edit the
redirectsitem - Save your changes
Changes propagate globally in under a second. No redeploy needed.
Copy link to headingUpdate via API
You can also update redirects programmatically using the Vercel API:
This is useful for building admin interfaces or integrating with CMS webhooks.
Reference: Global Config API
Copy link to headingAdvanced patterns
Copy link to headingPattern matching with path-to-regexp
The basic example uses exact path matching. For advanced patterns like wildcards, parameters, and regex matching, update your proxy.ts to use path-to-regexp (the same library that powers next.config.js redirects).
First, install path-to-regexp version 6.3.0 (the same version Next.js uses):
This ensures your redirect patterns work identically to next.config.js redirects. At runtime, your code still uses Next.js's bundled version (no duplication in your bundle).
Then update your proxy.ts:
This approach supports all the same patterns as next.config.js redirects:
Named parameters:
Wildcard matching:
Regex patterns:
Optional segments:
Why this works: Next.js bundles path-to-regexp internally, so you don't need to install any additional dependencies. You get the exact same path matching that next.config.js uses, but with the ability to update rules via Global Config.
Reference: Next.js path-to-regexp patterns
Copy link to headingLimitations and considerations
Copy link to headingGlobal Config size limits
Global Config has size limits per plan:
- Hobby: 8 KB
- Pro: 64 KB
- Enterprise: 512 KB
For most redirect use cases, 8 KB is plenty. A simple redirect rule is about 100 bytes, so you can fit roughly 80 rules in the Hobby plan limit.
If you need thousands of redirects, use Bulk Redirects instead.
Reference: Global Config limits
Copy link to headingProxy runs on every request
The matcher config determines which requests trigger your proxy. Be specific to avoid unnecessary Global Config reads:
Reference: Next.js proxy matcher
Copy link to headingGlobal Config reads are fast, but not free
Global Config reads are globally distributed and have no rate limits. However, reading on every request does add latency (typically 1-5ms). For most sites, this is negligible. For extremely high-traffic sites, consider using Bulk Redirects for static rules.
Copy link to headingTroubleshooting
Copy link to heading"Global Config not found" error
Make sure:
- Your Global Config is connected to your project
- The
GLOBAL_CONFIGenvironment variable exists in your project settings - You've deployed after connecting the Global Config
Copy link to headingRedirects not updating
Global Config changes should propagate in under a second. If they don't:
- Check the Global Config dashboard to confirm your changes saved
- Verify you're hitting the production deployment (not a preview)
- Clear your browser cache (browsers cache 307/308 redirects)
Copy link to headingProxy not running
Check your matcher config. Make sure your redirect paths aren't accidentally excluded. The default excludes _next, api, and static files.
Copy link to headingSummary
You now have redirects that update instantly without redeploying:
- Store redirect rules in Global Config
- Read them from Next.js proxy on each request
- Update rules via dashboard or API, changes propagate globally in under a second