This site is not affiliated with or endorsed by Vercel, Inc. Read the docs, then deploy or run each experiment yourself.
Developer Tools

Vercel Flags Lab

Evaluate platform-native Vercel Flags with entity targeting - local sticky simulator plus live flags-core.

Run this experiment yourself

Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.

Local development

cd apps/experiments/vercel-flags-lab
pnpm install
pnpm dev

Then open http://localhost:3010.

This is an experimental demo. Use it as a starting point for your own projects.

The Vercel Flags Lab covers platform-native Vercel Flags: define flags in the dashboard (or as code drafts), evaluate them with the Flags SDK / @vercel/flags-core, and target using entities such as user.plan. Pair it with the Global Config Lab when you need ultra-low-latency config reads alongside flags.

Features

  • Flags SDK definition. flags.ts exports marketingBanner with vercelAdapter() so drafts can surface in the dashboard.
  • Local targeting simulator. Sticky FNV bucket + plan rules (enterprise / beta) run entirely in the browser via evaluateLocalFlag.
  • Live evaluation. POST /api/flags/evaluate calls flagsClient.evaluate from @vercel/flags-core.
  • Honest setup errors. Missing OIDC or missing dashboard flag returns 503 with requirements.

UI Reference

ControlBehavior
Flag key / User ID / planEntities for local + live evaluation
Rollout % / Flag enabledLocal simulator only (evaluateLocalFlag in logic.ts)
Local statusUpdates as you edit - no network
Evaluate via Vercel FlagsHits the live Route Handler

Local mode never calls /api - the sticky simulator is pure client TypeScript.

API Reference

POST /api/flags/evaluate

Live Flags evaluation only. Local simulation stays in the UI.

Prop

Type

curl -X POST http://localhost:3010/api/flags/evaluate \
  -H 'content-type: application/json' \
  -d '{"key":"marketing-banner","userId":"user-7f3a","plan":"enterprise"}'
StatusCause
200Evaluated via @vercel/flags-core
400Invalid body
503Missing dashboard flag / OIDC - see requirements

Implementation Details

Code-defined flag:

apps/experiments/vercel-flags-lab/flags.ts
import { flag } from 'flags/next';
import { vercelAdapter } from '@flags-sdk/vercel';

export const marketingBanner = flag({
  key: 'marketing-banner',
  adapter: vercelAdapter(),
  defaultValue: false,
});

Live evaluation path:

apps/experiments/vercel-flags-lab/app/api/flags/evaluate/route.ts
const { flagsClient } = await import('@vercel/flags-core');
const result = await flagsClient.evaluate<boolean>(key, false, entities);

evaluateLocalFlag in logic.ts mirrors sticky rollout and plan overrides without calling the network.

Use Cases

  • Release features behind dashboard toggles without redeploying
  • Target enterprise / beta cohorts with entity attributes
  • Progressive percentage rollouts with sticky user assignment

Limitations

  • Live mode needs a flag in the Vercel project Flags UI and OIDC locally.
  • Local simulator is not the production evaluation engine - rules you configure in the dashboard are authoritative for live mode.
  • Embedded definitions and Flags Explorer behaviour appear after a real Vercel deploy.

Use in your project

  1. Create a flag in the dashboard (or deploy a flag({...}) draft)
  2. pnpm add flags @flags-sdk/vercel (and/or @vercel/flags-core)
  3. Evaluate in Server Components with await myFlag() or flagsClient.evaluate

Deployment

Deploy on Vercel

After deploy, create marketing-banner under Flags, toggle environments, and hit Evaluate via Vercel Flags in the demo.

Local Development

cd apps/experiments/vercel-flags-lab
pnpm install
vercel link && vercel env pull
pnpm dev

Unit tests:

pnpm vitest run ../experiments/vercel-flags-lab

Configuration

SetupRequiredNotes
Dashboard flag marketing-bannerLive modeBoolean recommended for this demo
OIDC (vercel env pull)Local live evalAutomatic on Vercel

Vercel / Next.js Features Used

Next Steps

On this page