惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
人人都是产品经理
人人都是产品经理
罗磊的独立博客
博客园 - 聂微东
雷峰网
雷峰网
量子位
美团技术团队
V
V2EX
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
The Cloudflare Blog
爱范儿
爱范儿
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
Jina AI
Jina AI

Flags SDK Documentation

Global Config Bulk Evaluation Evaluation Context Precompute GrowthBook Hypertune PostHog Split Evaluation Context Quickstart Precompute Evaluation Context Quickstart Precompute GrowthBook Hypertune PostHog Split Proxy Dashboard Pages Marketing Pages Dashboard Pages Marketing Pages Data Locality Providers LaunchDarkly Optimizely Reflag Statsig Server-side vs Client-side
Vercel
Vercel · 2026-04-03 · via Flags SDK Documentation

The @flags-sdk/vercel package connects the Flags SDK to Vercel's own feature flags platform called Vercel Flags, allowing you to manage flags directly in your Vercel projects.

Learn more about Vercel Flags

Learn more about Adapters

Install the Vercel adapter package:

pnpm i flags @flags-sdk/vercel

1. Create a feature flag in Vercel

Create your first feature flag in the Vercel dashboard:

You can create a simple boolean feature flag called example-flag for this quickstart.

When you create a flag, Vercel automatically configures these environment variables:

  • FLAGS - SDK Key for your Vercel Flags project
  • FLAGS_SECRET - Secret key used by Flags Explorer for flag overrides

2. Sync environment variables

Pull the environment variables to your local project using Vercel CLI:

You might need to run vercel link first in case you did not link your project to Vercel yet.

3. Declare the flag in your code

Use the vercelAdapter to connect your flag declaration to Vercel Flags:

import { flag } from 'flags/next';
import { vercelAdapter } from '@flags-sdk/vercel';

export const exampleFlag = flag({
  key: "example-flag",
  adapter: vercelAdapter()
});

The vercelAdapter() automatically uses the FLAGS environment variable to connect to your Vercel Flags project.

4. Use the flag

Call the flag as a function to resolve its value:

import { exampleFlag } from '../../flags';

export default async function Page() {
  const showExample = await exampleFlag();

  return <div>{showExample ? 'Hello world' : 'Not showing'}</div>
}

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.

Target specific users or groups by providing an identify function that returns context about the current user, team, or other entities.

import { dedupe, flag } from 'flags/next';
import { vercelAdapter } from '@flags-sdk/vercel';

type Entities = {
  team?: { id: string };
  user?: { id: string };
};

// Use dedupe to prevent redundant evaluation context lookups
// https://flags-sdk.dev/frameworks/next/evaluation-context#deduplication
const identify = dedupe(async (): Promise<Entities> => {
  return {
    team: { id: 'team-123' },
    user: { id: 'user-456' },
  };
});

export const exampleFlag = flag<boolean, Entities>({
  key: "example-flag",
  identify,
  adapter: vercelAdapter()
});

Configure which entities are available for targeting in your Vercel Flags project:

This allows you to create targeting rules in Vercel Flags based on your specific entity types (users, teams, organizations, etc.).

Flags Explorer provides a UI for viewing and overriding flags during development and testing.

To enable full integration, create a flags discovery endpoint:

import { createFlagsDiscoveryEndpoint } from 'flags/next';
import { getProviderData } from "@flags-sdk/vercel";
import * as flags from '../../../../flags';

export const GET = createFlagsDiscoveryEndpoint(async (request) => {
  return await getProviderData(flags);
});

This endpoint allows Flags Explorer to:

  • Discover all flags defined in your codebase
  • Show flag metadata and default values
  • Enable local overrides during development

Custom adapter configuration

To connect to a different Vercel Flags project or use a custom SDK Key:

import { flag } from 'flags/next';
import { createVercelAdapter } from '@flags-sdk/vercel';

const customAdapter = createVercelAdapter(
  process.env.CUSTOM_FLAGS_KEY!
);

export const exampleFlag = flag({
  key: "example-flag",
  adapter: customAdapter()
});