Getting Started with Vercel Flags
This guide walks you through creating a feature flag in the Vercel Dashboard and evaluating it in your application. By the end you'll have a working flag that you can toggle from the dashboard.
- A Next.js project connected to Vercel.
- Vercel CLI installed.
- Go to your Vercel Dashboard.
- Navigate to the Flags tab for your project.
- Create a new flag named
marketing-banner. - Leave the Type set to Boolean and configure the environment settings to be on for Development and off for Preview and Production.
When you create your first flag, Vercel provisions SDK Keys for each environment and stores them in a
FLAGSenvironment variable on your project. Pull them into your local.env.localfile:terminalvercel env pullIf your project isn't linked yet, run
vercel linkfirst.Toggle the flag for off for the Development environment in the Vercel Dashboard, then press Review and save and leave a message for the change. Reload the page to see the change.
The SDK can fetch your flag definitions once at build time and bundle them into the deployment. This guarantees every function uses the same snapshot during the build, and provides a runtime fallback if the Vercel Flags service is temporarily unreachable.
Embedding is experimental. Enable it by adding a
VERCEL_EXPERIMENTAL_EMBED_FLAG_DEFINITIONS=1 environment variable to your
project. This is recommended to avoid downtime during service outages, and
will become the default in a future release.
Learn more about embedded definitions.
Your flag is working. Here's what to explore next:
- Entities and targeting: Define user attributes and create rules to show flags to specific groups.
- Segments: Build reusable audience groups like "Beta Testers" or "Internal Team."
- Flags Explorer: Override flags in the Vercel Toolbar during development without affecting other users.
- Drafts: Define flags in code first, then promote them in the dashboard when you're ready.
- Observability: Track flag evaluations in Runtime Logs and Web Analytics.
- Managing flags: Configure rules, environments, and flag lifecycles in the dashboard.
Was this helpful?