SDK Keys
Vercel Flags supports OpenID Connect (OIDC) for applications in the same Vercel project. Use SDK Keys for manual authentication, including applications outside Vercel and projects that evaluate flags owned by another project.
Each SDK Key belongs to one 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 which key it uses. See environment configuration to learn how to configure flags per environment.
The FLAGS environment variable is the default environment variable name for SDK Key authentication.
Set each Vercel environment to the matching SDK Key:
| Vercel Environment | FLAGS value |
|---|---|
| Production | Production SDK Key |
| Preview | Preview SDK Key |
| Development | Development SDK Key |
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
- Open Flags in the sidebar
- Click SDK Keys in the sidebar
The list shows a masked preview of each key (for example, vf_server_abc********) so you can identify keys without exposing the secret value. The full key value is only shown once, at creation time. After that, Vercel never returns it again.
Create SDK Keys for manual credentials, such as cross-project evaluation or external environments.
- Go to the SDK Keys page for your project
- Click Create SDK Key, select the target environment, and give the key a descriptive label
- Copy the SDK key from the confirmation dialog, then click Done
To evaluate flags from a different project, use an SDK Key from the project that owns the flags.
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. Copy each key's full value from the confirmation dialog before closing it. Vercel only shows the value once.
- 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
- Copy the new SDK key from the confirmation dialog immediately, then click Done. The full value is shown only at creation and can't be recovered later.
- Update the environment variable that stores the key, such as
FLAGS, to use the new SDK Key for the target environment. Mark the value as sensitive for preview and production, while keeping the development key as non-sensitive. - Redeploy your application
- Delete the compromised SDK Key
After deletion, the old key stops working, so redeploy your application with the new key before deleting the old one. If you close the create dialog without copying the new key, delete it and start over.
Was this helpful?