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

推荐订阅源

G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
F
Fortinet All Blogs
H
Help Net Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
MyScale Blog
MyScale Blog
B
Blog
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
IT之家
IT之家
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
博客园_首页
L
LangChain Blog
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky

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 Statsig Server-side vs Client-side Flags as Code
Reflag
Vercel · 2026-04-03 · via Flags SDK Documentation

The Reflag provider contains support for Reflag's feature management tools.

Reflag is agent-ready feature flags for TypeScript

The @flags-sdk/reflag provider package exports

  • An adapter for flags from Reflag.
  • A getProviderData function for use with the Flags Explorer.

Learn more about Adapters

Learn more about the Flags Explorer

Deploy the Reflag template


The Reflag provider is available in the @flags-sdk/reflag module. Install it with

npm install @flags-sdk/reflag

Import the default adapter instance reflagAdapter from @flags-sdk/reflag:

import { reflagAdapter } from "@flags-sdk/reflag";

If you need a customized setup, you can import createReflagAdapter from @flags-sdk/reflag and create an adapter instance with your settings:

import { createReflagAdapter } from "@flags-sdk/reflag";

const reflagAdapter = createReflagAdapter({
  secretKey: process.env.REFLAG_SECRET_KEY,
});

See the Reflag NodeSDK documentation for the full list of options.


The Reflag provider uses the identify property to identify users and companies. The identify function is called for every request to determine the user and company context.

Reflag relies on a setting a user/company to evaluate flags for a given request.

Set the identify property to a function which returns a Reflag Context containing user/company properties:

import { dedupe, flag } from "flags/next";
import type { Identify } from "flags";
import { reflagAdapter, type Context } from "@flags-sdk/reflag";

const identify = dedupe((async ({ headers, cookies }) => {
  // Your own logic to identify the user
  // Identifying the user should rely on reading cookies and headers only, and
  // not make any network requests, as it's important to keep latency low here.
  const user = await getUser(headers, cookies);

  return {
    user: {
      id: user.id,
      name: user.name,
      email: user.email,
    },
    company: {
      id: user.companyId,
    },
  } satisfies Context;
}) satisfies Identify<Context>);

export const myFeature = flag<boolean, Context>({
  key: "my_feature",
  identify,
  adapter: reflagAdapter.isEnabled(),
});

Learn more about identify


Feature toggling

Through the featureIsEnabled method, the Reflag provider supports determining if features are enabled/disabled.

export const myFeature = flag<boolean, Context>({
  key: "my_feature",
  adapter: reflagAdapter.isEnabled(),
  identify,
});

Remote Config, Adoption tracking and automatic feedback surveys are currently not supported in the Reflag Flags SDK provider.


"Checks" events

Check events are used to log when a user is exposed to a feature. Because middleware and server components are evaluated when routes are prefetched, check events are not supported in the Reflag Provider.

See the Reflag React SDK documentation for more information on how to use check events in the client.


View and override your Reflag feature toggles using the Flags Explorer.

To make Flags Explorer aware of your Reflag features, you need to provide a route which Flags Explorer will load your experiment metadata from.

Use the getProviderData function in your Flags API endpoint to load and emit your Reflag data. getProviderData takes a ReflagClient in the options object:

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

export const GET = createFlagsDiscoveryEndpoint(async () => {
  return getProviderData({
    reflagClient: await reflagAdapter.reflagClient(),
  });
});

Read more about Reflag, Flags SDK, and the Reflag adapter.