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

推荐订阅源

Recent Announcements
Recent Announcements
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
量子位
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
博客园 - Franky
M
MIT News - Artificial intelligence
U
Unit 42
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
J
Java Code Geeks
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MyScale Blog
MyScale Blog
T
Tailwind CSS Blog
T
The Blog of Author Tim Ferriss
V
V2EX

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
Dedupe
Vercel · 2026-04-03 · via Flags SDK Documentation

Prevent duplicate work by deduplicating function calls.

Any function wrapped in dedupe will only ever run once for the same request within the same runtime and given the same arguments.

The dedupe function is an integral piece when working with the Flags SDK.

import { dedupe } from 'flags/next';

const dedupeExample = dedupe(() => {
  return Math.random();
});

export default async function Page() {
  const random1 = await dedupeExample();
  const random2 = await dedupeExample();
  const random3 = await dedupeExample();

  // these will all be the same random number
  return (
    <div>
      {random1} {random2} {random3}
    </div>
  );
}

Example of output:

Avoiding duplicate work

This helper is useful in combination with the identify function, as it allows the identification to only happen once per request. This prevents overhead when passing the same identify function to multiple feature flags, or when using the same flag multiple times.

Generating consistent random IDs

When experimenting on anonymous visitors it is common to set a cookie containing a random id from Proxy. This random id is later used to consistently assign users to specific groups of A/B tests.

For this use case, the function generating the random id can be wrapped in dedupe. The deduplicated function is then called in Routing Functions to produce the random id, and from a flag's identify function to identify the user even on the first page visit when no cookie is present yet.

As the function is guaranteed to generate the same id the Routing Functions can set a cookie containing the generated id in a response, and the feature flag can already use the generated id even if the original request did not contain the id.

Note that dedupe is not available in Pages Router.

See the Marketing Pages example