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.
- Open Flags in the sidebar 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 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.
Now that your flag is working, you can add an
identifyfunction to pass user and team context for targeting rules. This lets you roll out flags to specific users, plans, or teams from the dashboard.
When you deploy to Vercel, the build process fetches your latest flag definitions once at build time and bundles 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. Definitions are only fetched when your project has at least one environment variable containing an SDK key for Vercel Flags.
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?