mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
c0d8224015
Update docs and examples to pass the adapter factory directly (adapter: vercelAdapter) instead of calling it (adapter: vercelAdapter()), reflecting the AdapterOrFactory support in flag(). Applied consistently to all zero-arg factory adapters (vercel, edge-config, custom adapter examples). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@flags-sdk/edge-config
Installation
npm install @flags-sdk/edge-config
Usage
Using the default adapter
This adapter will connect to the Edge Config available under the EDGE_CONFIG environment variable, and read items from a key in the Edge Config called flags.
import { flag } from "flags/next";
import { edgeConfigAdapter } from "@flags-sdk/edge-config";
export const exampleFlag = flag({
key: "example-flag",
adapter: edgeConfigAdapter,
});
Your Edge Config should look like this:
{
"flags": {
"example-flag": true
}
}
Using a custom adapter
You can specify a custom adapter which connects to a different Edge Config, and reads
import { flag } from "flags/next";
import { createEdgeConfigAdapter } from "@flags-sdk/edge-config";
const edgeConfigAdapter = createEdgeConfigAdapter(process.env.EDGE_CONFIG, {
teamSlug: "your-team-slug",
edgeConfigItemKey: "my-flags",
});
export const exampleFlag = flag({
key: "example-flag",
adapter: edgeConfigAdapter,
});
Your Edge Config should look like this:
{
"my-flags": {
"example-flag": true
}
}
Supplying the custom teamSlug allows the adapter to generate an origin for your flags, which in turn allows the Flags Explorer to link to your Edge Config. This is optional and does not affect runtime behavior.