Vercel Edge Config doesn’t just serve feature flags; it fundamentally redefines how applications make dynamic decisions by pushing that logic to the network’s edge.
Let’s see it in action. Imagine you have a Vercel project and you want to enable a new "AI-powered search" feature for a subset of your users.
First, you’d install the @vercel/edge-config SDK:
npm install @vercel/edge-config
# or
yarn add @vercel/edge-config
Then, in your Vercel project’s settings, you’d navigate to "Edge Config" and create a new configuration. Let’s call it my-feature-flags. You’d then add a key-value pair, for instance:
Key: aiSearchEnabled
Value: true
This my-feature-flags configuration is now accessible globally via a unique endpoint, managed by Vercel’s global network.
In your application code, typically within an Edge Function or Serverless Function that runs close to your users, you’d fetch this configuration.
import { get } from '@vercel/edge-config';
export async function middleware(request) {
const aiSearchEnabled = await get('aiSearchEnabled');
if (aiSearchEnabled) {
// Redirect to the AI-powered search page or enable the feature
return Response.redirect(new URL('/ai-search', request.url));
}
// Continue with the existing search logic
return Response.next();
}
When a user in, say, Sydney, Australia, hits your application, the get('aiSearchEnabled') call doesn’t go back to your origin server. Instead, it queries the nearest Vercel Edge Network node. This node has a cached, up-to-date copy of your my-feature-flags configuration. The response is milliseconds, not hundreds of milliseconds.
The core problem Edge Config solves is the latency inherent in fetching dynamic configuration from a central server. Traditional feature flagging systems often involve API calls that add significant round-trip time, especially for users geographically distant from your data center. By distributing this configuration data across Vercel’s edge network, it becomes available virtually instantaneously.
This isn’t just about feature flags. You can store any small, frequently accessed configuration data here: A/B test variations, API endpoints, user segmentation rules, or even dynamic UI elements. The key is that the data needs to be available with minimal latency and updated relatively infrequently (though updates propagate globally within seconds).
The system works by having your Edge Config data replicated across Vercel’s global fleet of edge nodes. When you update a value in the Vercel dashboard, a change event is triggered. This event is picked up by Vercel’s internal infrastructure, which then pushes the updated configuration to all edge nodes. The @vercel/edge-config SDK on the client-side (or in your Edge/Serverless Functions) queries the local edge node for the data, leveraging the cached, replicated copy. This is why the latency is so low – it’s a local cache hit.
The get() function is actually an asynchronous operation because it needs to perform a network request to the nearest edge node. However, because these nodes are globally distributed and the data is cached, the latency is drastically reduced compared to a single origin server. You can also pass a cache option to get(), like get('myKey', { cache: 'force-cache' }), to instruct the SDK to aggressively cache the value, further reducing latency for subsequent requests within a short timeframe.
When you update a value in Edge Config, Vercel doesn’t just update one location. It orchestrates a global distribution process. The system leverages a distributed key-value store that is actively replicated across Vercel’s edge network. When a write operation occurs, it’s propagated through a consensus mechanism to ensure eventual consistency across all nodes. The SDK, when it performs a get(), hits the nearest edge node, which already has a recent copy of the data. This is why the propagation is fast but not instantaneous – there’s a brief window where different edge nodes might have slightly different versions of the data.
The next concept you’ll likely explore is how to manage more complex configuration states and integrate Edge Config with other Vercel features like A/B testing and analytics.