Vercel Flags
Vercel Flags is a feature flag provider built into Vercel's platform, allowing you to manage flags directly in your Vercel projects. The @flags-sdk/vercel package connects the Flags SDK to Vercel Flags.
Vercel Flags is now available — read the announcement
Learn more about Vercel Flags
Installation
Install the Vercel adapter package:
If you use an AI coding assistant, install the agent skills: flags-sdk for the code, and vercel-flags for planning flags, the vercel flags CLI, rollouts, and experiments:
Quickstart
Create a feature flag in Vercel
Create your first feature flag in the Vercel dashboard:
Create Flag
You can create a boolean feature flag called example-flag for this quickstart.
When you create your first flag, Vercel activates Vercel Flags for the project and creates a FLAGS_SECRET environment variable for each environment. Flags Explorer uses it for flag overrides.
Sync environment variables
Vercel Flags authenticates with the Vercel OpenID Connect (OIDC) token of your project. Deployments receive this token automatically. For local development, pull the environment variables to your .env.local file using Vercel CLI:
You might need to run vercel link first in case you did not link your project to Vercel yet.
Declare the flag in your code
Use the vercelAdapter to connect your flag declaration to Vercel Flags:
The vercelAdapter authenticates with the OIDC token of your project and evaluates the flags of the current environment. If you set a FLAGS environment variable, the adapter uses that SDK key instead. See SDK keys for when you need one.
Use the flag
Call the flag as a function to resolve its value:
You can now toggle the feature flag for the development environment on the Vercel dashboard and you should see the updated flag value locally after reloading the page.
User targeting
Target specific users or groups by providing an identify function that returns context about the current user, team, or other entities.
Configure which entities are available for targeting in your Vercel Flags project:
Configure Entities
This allows you to create targeting rules in Vercel Flags based on your specific entity types (users, teams, organizations, etc.).
Flags Explorer integration
Flags Explorer provides a UI for viewing and overriding flags during development and testing.
To enable full integration, create a flags discovery endpoint:
This endpoint allows Flags Explorer to:
- Discover all flags defined in your codebase
- Show flag metadata and default values
- Enable local overrides during development
Advanced configuration
Read a connected project's flags
Project Connections let your project read flags from another project in the same team without an SDK key. With the Flags SDK, use @flags-sdk/vercel version 1.6.0 or later. In the source project's Flags → Connections page, grant your project access. Then pass the source project's ID to createVercelAdapter:
The adapter uses your project's OIDC token. Keep vercelAdapter for flags owned by your project. For local development, run vercel env pull in your project.
Set up the connection before your app evaluates the connected flags. Check it with vercel flags connections list --project <source>. If the client's first request is rejected with 401 because access is missing, it does not retry and serves defaultValue until the process restarts. If a connected flag only returns its default value, verify the connection, then restart your dev server or redeploy.
Connections grant read access across environments. Your deployment's token selects the source environment: production reads production, preview reads preview, and local development reads development. Custom environments use preview. The projectId option cannot be combined with an SDK key.
If you use the core library directly, use @vercel/flags-core version 1.11.0 or later. The adapter includes the required core library version.
Managing connections with vercel flags connections requires Vercel CLI version 63.0.0 or later. See Project Connections for permissions and connection management.
SDK keys
You do not need an SDK key when your app runs on Vercel and reads its own or a connected project's flags. Use an SDK key for apps outside Vercel or when you need to select an environment explicitly. Create the key in the Vercel dashboard and pass it to createVercelAdapter:
Learn more about SDK keys