Vercel Edge Config and Feature Flags
Use Vercel configuration reads for feature flags, routing, and maintenance controls, with latency and propagation considerations.
Feature-flag reads can add request latency when they depend on a remote service. Vercel Edge Config provides a configuration store for values that are read frequently and changed less often.
What Vercel Edge Config Is
Edge Config is now named Global Config. Existing Edge Config projects and package usage remain supported. Vercel replicates configuration alongside function code, allowing locally available reads without an upstream request.
Vercel reports typical reads below a millisecond on its platform, with latency dependent on usage patterns. Measure the behavior for your application.
Updates require replication. Confirm propagation behavior and failure handling before using configuration changes as operational controls.
Architecture: How Edge Config Works With Edge Middleware
Configuration reads can run in middleware for matched requests, allowing routing decisions before the destination handler.
// middleware.ts
import { NextResponse } from "next/server";
import { get } from "@vercel/edge-config";
export async function middleware(request) {
const maintenanceMode = await get("maintenance_mode");
if (maintenanceMode === true) {
return NextResponse.rewrite(new URL("/maintenance", request.url));
}
return NextResponse.next();
}
This middleware reads a flag for requests it matches. Measure read latency and handle unavailable or unexpected values. The diagram’s sub-millisecond figure is illustrative, not a latency guarantee.
The same pattern extends to:
- A/B test variant assignment
- Gradual feature rollouts
- Geolocation-based content decisions
- Kill switches for specific features
Use Cases Where Edge Config Fits
Feature Flags at the Routing Layer
Feature flags implemented at the middleware layer run before any page or API route logic. This means you can redirect users to a different URL, serve a completely different page, or short-circuit API calls based on a flag — without any flag evaluation cost in your application code.
For simple on/off routing and redirect rules, the configuration store may cover the required behavior. Experiment exposure tracking and more complex targeting require additional implementation or a suitable platform.
Maintenance Mode and Traffic Routing
A maintenance flag can change request routing without a code deployment. Test propagation and the maintenance route before relying on it during an incident.
Assign access to configuration changes and record how operators verify that a change has taken effect.
A/B Test Assignment
For simple A/B tests where variant assignment is random or cookie-based, Edge Config can hold the experiment configuration (variant weights, start/end dates, eligible routes). The middleware assigns the variant, sets a cookie, and routes the request accordingly.
For statistically valid experimentation requiring exposure tracking and analysis, you still need a dedicated experimentation platform. Edge Config handles the routing and configuration; event tracking goes to your analytics system.
Rate Limiting Thresholds and Allow/Block Lists
Edge Config can store configuration that changes your rate limiting behavior — request limits per IP range, blocked user agents, allowed API key prefixes. Reading these values in middleware at sub-millisecond cost means you can enforce dynamic limits without adding network latency to every request.
Setting Up Edge Config
Edge Config is available on Vercel Pro and Enterprise plans. Setup:
- Create an Edge Config store in the Vercel dashboard
- Connect it to your project under Project Settings
- Install the SDK:
npm install @vercel/edge-config - Read values in middleware or edge functions using
get,getAll, orhas
To write values to Edge Config programmatically (from a deployment hook, a CI pipeline, or an admin dashboard), use the Vercel API:
PATCH https://api.vercel.com/v1/edge-config/{edgeConfigId}/items
Authorization: Bearer {token}
{
"items": [
{ "operation": "upsert", "key": "feature_checkout_v2", "value": true }
]
}
This API call updates the value in Edge Config and triggers propagation to all edge nodes.
Limits and Constraints to Know
- Read latency: Under 1ms at the edge PoP. Reads in server-side Next.js routes (not middleware/edge functions) go over the network and have standard API latency.
- Write propagation: Roughly 300ms global propagation after a write via the API.
- Value size: Individual values have a size limit; the store has an overall size limit. Edge Config is not a database — keep values small and flat.
- Read-heavy design: Edge Config is optimized for reads, not writes. If your configuration changes more than a few times per minute, Edge Config is not the right tool.
- Not for user-specific data: Edge Config is global configuration, not per-user state. Do not put user data in Edge Config.
Combining Edge Config With Other Feature Flag Systems
A practical pattern for teams with an existing feature flag platform (LaunchDarkly, Split, Statsig):
- Edge Config holds the routing-layer flags — kill switches, maintenance mode, A/B test routing — that must be evaluated on every request with sub-millisecond overhead
- The feature flag SDK runs in your application code for user-targeting, percentage rollouts, and experiment tracking that require richer targeting rules and event logging
This layered approach keeps the edge layer fast and simple while preserving the analytical capabilities of a full experimentation platform for application-level decisions.
When to Choose a Different Approach
Edge Config is the right tool when:
- You need configuration reads in Vercel Middleware or Edge Functions
- The configuration changes deliberately, not continuously
- Values are small and few (dozens to low hundreds of keys)
Consider alternatives when:
- You need user-level targeting with complex rules — use a dedicated feature flag SDK
- You need configuration with sub-second write propagation — Edge Config's 300ms window may be too slow for fast-moving state
- Your application does not run on Vercel — Edge Config is Vercel-specific
Compare read latency, update propagation, limits, and operating costs with the application’s requirements before choosing Edge Config.