mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
ba4eec7b23
* remove @pyra/eslint-config * wip * wip * convert shirt-shop-api * convert shirt-shop * convert snippets * convert next-13 * convert next-14 * convert next-15 * eslint configs * upgrade prettier * use eslint v9 * run prettier * resolve type-check * adjust eslint * drop Next.js v13 * fix next-14 Avoid accidentally using implicitly installed eslint v8 * update lockfile * rm @eslint/eslintrc * add @next/eslint-plugin-next * biome * biome fixes * wip * apply formatting * tabs * rm prettier * spaces * fix svelte * update lockfile * single quotes * format all * rm eslint-disable comments * upgrade playwright * upgrade publint * upgrade playwright ci workflow * try chromium headless * try adding executablePath
65 lines
1.3 KiB
Markdown
65 lines
1.3 KiB
Markdown
# `@flags-sdk/edge-config`
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
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`.
|
|
|
|
```ts
|
|
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:
|
|
|
|
```json
|
|
{
|
|
"flags": {
|
|
"example-flag": true
|
|
}
|
|
}
|
|
```
|
|
|
|
## Using a custom adapter
|
|
|
|
You can specify a custom adapter which connects to a different Edge Config, and reads
|
|
|
|
```ts
|
|
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:
|
|
|
|
```json
|
|
{
|
|
"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.
|