
Company News
Socket Named to Rising in Cyber 2026 List of Top Cybersecurity Startups
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.
@vercel/edge-config
Advanced tools
The official JavaScript client for reading from Vercel Edge Config — an ultra-low latency data store for global configuration data.
npm install @vercel/edge-config
process.env.EDGE_CONFIGimport { get } from '@vercel/edge-config';
// Read a single value
const value = await get('myKey');
// Check if a key exists
import { has } from '@vercel/edge-config';
const exists = await has('myKey'); // true or false
// Read multiple values at once
import { getAll } from '@vercel/edge-config';
const values = await getAll(['keyA', 'keyB', 'keyC']);
// Read all values
const allValues = await getAll();
Add Edge Config bundling for resilience and faster builds:
{
"scripts": {
"prebuild": "edge-config prepare"
}
}
This bundles a snapshot of your Edge Config into your build as a fallback, ensuring your application continues working in the rare event the Edge Config service is temporarily unavailable.
These functions read from the Edge Config specified in process.env.EDGE_CONFIG.
get(key)Reads a single value from Edge Config.
import { get } from '@vercel/edge-config';
const value = await get('myKey');
Returns:
undefined if the key does not existThrows:
has(key)Checks if a key exists in Edge Config.
import { has } from '@vercel/edge-config';
const exists = await has('myKey');
Returns:
true if the key existsfalse if the key does not existThrows:
getAll(keys?)Reads multiple or all values from Edge Config.
import { getAll } from '@vercel/edge-config';
// Get specific keys
const some = await getAll(['keyA', 'keyB']);
// Get all keys
const all = await getAll();
Parameters:
keys (optional): Array of keys to retrieve. If omitted, returns all items.Returns:
Throws:
digest()Gets the current digest (version hash) of the Edge Config.
import { digest } from '@vercel/edge-config';
const currentDigest = await digest();
Returns:
Throws:
Use createClient() to connect to a specific Edge Config or customize behavior.
createClient(connectionString, options?)Creates a client instance for a specific Edge Config.
import { createClient } from '@vercel/edge-config';
const client = createClient(process.env.ANOTHER_EDGE_CONFIG);
await client.get('myKey');
Parameters:
connectionString (string): The Edge Config connection stringoptions (object, optional): Configuration optionsOptions:
{
// Fallback to stale data for N seconds if the API returns an error
staleIfError?: number | false;
// Disable the default development cache (stale-while-revalidate)
disableDevelopmentCache?: boolean;
// Control Next.js fetch cache behavior
cache?: 'no-store' | 'force-cache';
// Timeout for network requests in milliseconds
// Falls back to bundled config if available, or throws if not
timeoutMs?: number;
}
Returns:
get(), getAll(), has(), and digest() methodsExample with options:
const client = createClient(process.env.EDGE_CONFIG, {
timeoutMs: 750,
cache: 'force-cache',
staleIfError: 300, // Use stale data for 5 minutes on error
});
clone(value)Creates a mutable copy of a value returned from Edge Config.
import { get, clone } from '@vercel/edge-config';
const value = await get('myKey');
const mutableValue = clone(value);
mutableValue.someProperty = 'new value'; // Safe to modify
Why this is needed: For performance, Edge Config returns immutable references. Mutating values directly may cause unexpected behavior. Use clone() when you need to modify returned values.
Bundling creates a build-time snapshot of your Edge Config that serves as a fallback and eliminates network requests during builds.
Setup:
{
"scripts": {
"prebuild": "edge-config prepare"
}
}
Benefits:
How it works:
edge-config prepare command scans environment variables for connection stringsSet a maximum wait time for Edge Config requests:
import { createClient } from '@vercel/edge-config';
const client = createClient(process.env.EDGE_CONFIG, {
timeoutMs: 750,
});
Behavior:
Recommendation: Only use timeouts when you have bundling enabled or proper error handling.
Edge Config is optimized for high-volume reads and infrequent writes. Update values using:
By default, Edge Config triggers dynamic rendering:
import { get } from '@vercel/edge-config';
export default async function Page() {
const value = await get('myKey');
return <div>{value}</div>;
}
To use Edge Config with static pages, enable caching:
import { createClient } from '@vercel/edge-config';
const client = createClient(process.env.EDGE_CONFIG, {
cache: 'force-cache',
});
export default async function Page() {
const value = await client.get('myKey');
return <div>{value}</div>;
}
Note: Static rendering may display stale values until the page is rebuilt.
// pages/api/config.js
import { get } from '@vercel/edge-config';
export default async function handler(req, res) {
const value = await get('myKey');
res.json({ value });
}
// pages/api/edge.js
import { get } from '@vercel/edge-config';
export default async function handler(req) {
const value = await get('myKey');
return new Response(JSON.stringify({ value }));
}
export const config = { runtime: 'edge' };
Vite doesn't automatically expose .env variables on process.env. Choose one solution:
Option 1: Populate process.env with dotenv-expand
pnpm install --save-dev dotenv dotenv-expand
// vite.config.js
import dotenvExpand from 'dotenv-expand';
import { loadEnv, defineConfig } from 'vite';
export default defineConfig(({ mode }) => {
if (mode === 'development') {
const env = loadEnv(mode, process.cwd(), '');
dotenvExpand.expand({ parsed: env });
}
return {
// Your config
};
});
Option 2: Pass connection string explicitly
// SvelteKit example
import { createClient } from '@vercel/edge-config';
import { EDGE_CONFIG } from '$env/static/private';
const client = createClient(EDGE_CONFIG);
await client.get('myKey');
Enable tracing for observability:
import { setTracerProvider } from '@vercel/edge-config';
import { trace } from '@opentelemetry/api';
setTracerProvider(trace);
For verbose traces, set the environment variable:
EDGE_CONFIG_TRACE_VERBOSE=true
Edge Config throws errors in these cases:
timeoutMs and no bundled fallback is availableExample:
import { get } from '@vercel/edge-config';
try {
const value = await get('myKey');
} catch (error) {
console.error('Failed to read Edge Config:', error);
// Handle error appropriately
}
Values returned by get() and getAll() are immutable by default. Do not modify them directly:
// BAD - Do not do this
const value = await get('myKey');
value.property = 'new value'; // Causes undefined behavior
// GOOD - Clone first
import { clone } from '@vercel/edge-config';
const value = await get('myKey');
const mutableValue = clone(value);
mutableValue.property = 'new value'; // Safe
Why? For performance, the SDK returns references to cached objects. Mutations can affect other parts of your application.
Found a bug or want to contribute?
npm linknpm link @vercel/edge-confignpm testThe `config` package is a popular choice for managing configuration settings in Node.js applications. It allows for configuration files to be organized by environment and provides a simple API for accessing these settings. Unlike @vercel/edge-config, it does not provide edge-specific features or dynamic updates without redeployment.
The `dotenv` package is used to load environment variables from a `.env` file into `process.env`. It is widely used for managing configuration in Node.js applications. However, it lacks the dynamic and edge-specific capabilities of @vercel/edge-config.
The `feature-toggle` package provides a way to manage feature flags in Node.js applications. It allows for enabling or disabling features based on configuration settings. While it offers some similar functionality to @vercel/edge-config, it does not provide the same level of integration with edge environments.
FAQs
Ultra-low latency data at the edge
The npm package @vercel/edge-config receives a total of 443,010 weekly downloads. As such, @vercel/edge-config popularity was classified as popular.
We found that @vercel/edge-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.

Security News
A dispute over fsnotify maintainer access set off supply chain alarms around one of Go’s most widely used filesystem libraries.