SDK Keys
When your application evaluates a feature flag, it needs to connect to Vercel Flags to read the flag's configuration. SDK Keys make this possible by authenticating your application and selecting the right environment.
Projects typically have three SDK Keys, one per environment:
- Production SDK Key → Uses Production configuration
- Preview SDK Key → Uses Preview configuration
- Development SDK Key → Uses Development configuration
Because each key is scoped to an environment, the same application code can resolve flags differently depending on where it runs. See environment configuration to learn how to configure flags per environment.
SDK Keys are secrets. Each key grants read-only access to the full flag configuration for its environment, including any data used in targeting rules such as email addresses. Don't expose SDK Keys in client-side code or commit them to version control.
When you create your first feature flag, Vercel automatically provisions an SDK Key for each environment and adds a FLAGS environment variable to your project using these keys:
| Vercel Environment | FLAGS value |
|---|---|
| Production | Production SDK Key |
| Preview | Preview SDK Key |
| Development | Development SDK Key |
The special things about the FLAGS environment variable are
- it's automatically populated by Vercel when you create your first feature flag
- the default clients of the SDKs are connected to this variable
You are free to manually create SDK Keys, store them in any environment variable, and create SDK clients connected to them.
The default vercelAdapter() function reads from the FLAGS environment variable:
import { vercelAdapter } from '@flags-sdk/vercel';
export const myFlag = flag({
key: 'my-flag',
adapter: vercelAdapter(),
});To use a specific SDK Key, pass it to createVercelAdapter:
import { createVercelAdapter } from '@flags-sdk/vercel';
const vercelAdapter = createVercelAdapter(process.env.MY_CUSTOM_FLAGS_KEY);
export const myFlag = flag({
key: 'my-flag',
adapter: vercelAdapter(),
});If you create a VercelProvider without passing an SDK key it will read from the FLAGS environment variable:
import { OpenFeature } from '@openfeature/server-sdk';
import { VercelProvider } from '@vercel/flags-core/openfeature';
const vercelProvider = new VercelProvider();
await OpenFeature.setProviderAndWait(vercelProvider);
const client = OpenFeature.getClient();
await client.getBooleanValue('my-flag', false); // usage exampleTo use a specific SDK Key, pass it to VercelProvider:
import { OpenFeature } from '@openfeature/server-sdk';
import { VercelProvider } from '@vercel/flags-core/openfeature';
const vercelProvider = new VercelProvider(process.env.MY_CUSTOM_FLAGS_KEY);
await OpenFeature.setProviderAndWait(vercelProvider);
const client = OpenFeature.getClient();
await client.getBooleanValue('my-flag', false); // usage exampleThe default flagsClient reads from the FLAGS environment variable:
import { flagsClient } from '@vercel/flags-core';
await flagsClient.evaluate("my-flag"); // usage exampleTo use a specific SDK Key, pass it to createClient:
import { createClient } from '@vercel/flags-core';
const client = createClient(process.env.MY_CUSTOM_FLAGS_KEY);
await client.evaluate("my-flag"); // usage exampleTo see your project's SDK Keys:
- Navigate to your project in the Vercel Dashboard
- Go to the Flags tab
- Click SDK Keys in the sidebar
Here you can view the keys for each environment. Use these when you need to configure SDK Keys manually, such as for custom environments.
SDK Keys are secrets. Each key grants read-only access to the full flag configuration for its environment, including any data used in targeting rules such as email addresses. Don't expose SDK Keys in client-side code or commit them to version control.
Each SDK Key is scoped to a single project. By default, an application can only evaluate flags defined in its own project. To evaluate flags from a different project, you need an SDK Key from that project.
This is useful when multiple applications share the same flags, for example in a microfrontend setup or when a shared feature flag controls behavior across several services.
This example uses two projects: Project A owns the flags, and Project B needs to evaluate them.
- In Project A (the project that owns the flags), go to Flags → SDK Keys and click Create SDK Key. Create one key per environment (Development, Preview, Production). Use Project B's name as the label so you can tell which keys belong to which consumer.
- In Project B (the project that evaluates the flags), add the keys from step 1 as an environment variable — for example
PROJECT_A_FLAGS_KEY— setting each environment to the corresponding key. - In Project B's code, create an adapter or client using that variable:
import { flag } from 'flags/next';
import { createVercelAdapter } from '@flags-sdk/vercel';
const projectAAdapter = createVercelAdapter(
process.env.PROJECT_A_FLAGS_KEY,
);
export const sharedFlag = flag({
key: 'shared-flag',
adapter: projectAAdapter(),
});Project B can use vercelAdapter() for its own flags and the custom adapter for Project A's flags side by side. See How to use SDK Keys for examples with OpenFeature and the core library.
If you need to rotate an SDK Key, for example, if it was accidentally exposed:
- Go to the SDK Keys section
- Click Create SDK Key and create a new key for the environment you want to rotate
- Update the
FLAGSenvironment variable to use the new SDK Key for the target environment - Redeploy your application
- Delete the compromised SDK Key
After deletion, the old key will no longer work, so make sure to redeploy your application with the new key before deleting the old key.
Was this helpful?