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

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

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 Marketing Pages Dashboard Pages Marketing Pages Data Locality Providers LaunchDarkly Optimizely Reflag Statsig Server-side vs Client-side Flags as Code
Dashboard Pages
Vercel · 2026-05-28 · via Flags SDK Documentation

Use feature flags on dashboard pages.

Dashboard pages are rendered at request time, and may require authenticated users.

The example below shows how to use feature flags to show a feature to specific users on a dashboard page. They are flagged in based on their user id. The buttons below allow you to either act as a flagged in user or as a regular user.

The example above works by first defining a feature flag.

import type { ReadonlyRequestCookies } from 'flags';
import { flag, dedupe } from 'flags/next';

interface Entities {
  user?: { id: string };
}

const identify = dedupe(
  ({ cookies }: { cookies: ReadonlyRequestCookies }): Entities => {
    const userId = cookies.get('dashboard-user-id')?.value;
    return { user: userId ? { id: userId } : undefined };
  },
);

export const dashboardFlag = flag<boolean, Entities>({
  key: 'dashboard-flag',
  identify,
  decide({ entities }) {
    if (!entities?.user) return false;
    // Allowed users could be loaded from Edge Config or elsewhere
    const allowedUsers = ['user1'];

    return allowedUsers.includes(entities.user.id);
  },
});

The definition includes an identify function. The identify function is used to establish the evaluation context.

The example reads the user id directly from the cookie. In a real dashboard you would likely read a signed JWT instead.

Any server-side code can evaluate the feature flag by calling it.

export default async function DashboardPage() {
  const dashboard = await dashboardFlag();
  // do something with the flag
  return <div>Dashboard</div>;
}

Since dashboard pages are typically dynamic anyhow the async call to evaluate the feature flag should fit right in.

The example flag calls identify to establish the evaluation context. This function returns the entities that are used to evaluate the feature flag.

The decide function then later gets access to the entities returned from the identify function.

Learn more about identify

Evaluation Context

Feature Flags used on dashboards will usually run in the Serverless Function Region, close to the database. This means it is acceptable for a feature flag's decide function to read the database when establishing the evaluation context. However, ideally, it would only read from the JWT as this will lead to lower overall latency.

The identify call uses dedupe to avoid duplicate work when multiple feature flags depend on the same evaluation context.