@vercel/edge-config

Read global configuration at sub-millisecond speed — no database round-trips for critical runtime data.

@vercel/edge-config

Node.js

Read global configuration at sub-millisecond speed — no database round-trips for critical runtime data.

Fit

Bundle (gzip)

3.4 kB

10.4 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

Some data needs to be read on every request but changes rarely — feature flags, kill switches, maintenance mode toggles, allowed IP lists, A/B test configs. The typical approach is to:

  • Store it in a database and add latency to every request
  • Hard-code it in environment variables and redeploy every change
  • Use Redis/Upstash which still adds a network round-trip

None of these are ideal when you need a change to take effect globally in under a second with near-zero read latency.

What It Does

Edge Config is a global, ultra-low-latency key-value data store. Reads happen in under 1ms because the data is stored at the edge — co-located with your serverless functions and edge middleware. Updates propagate globally in seconds. It's designed specifically for configuration data that's read often but written rarely.

Installation

bash
npm install @vercel/edge-config

Usage Example

Read a value

ts
import { get } from "@vercel/edge-config";

export async function middleware(request: NextRequest) {
  const isMaintenanceMode = await get("maintenance_mode");

  if (isMaintenanceMode) {
    return NextResponse.rewrite(new URL("/maintenance", request.url));
  }

  return NextResponse.next();
}

Feature flag check in a route handler

ts
import { get } from "@vercel/edge-config";

export async function GET() {
  const newCheckoutEnabled = await get<boolean>("new_checkout");

  return Response.json({ feature: newCheckoutEnabled ?? false });
}

Read multiple values at once

ts
import { getAll } from "@vercel/edge-config";

const config = await getAll(["feature_x", "feature_y", "rate_limit"]);
// { feature_x: true, feature_y: false, rate_limit: 100 }

Check if a key exists

ts
import { has } from "@vercel/edge-config";

const exists = await has("beta_users_list");

Related packages