-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# `@flags-sdk/launchdarkly` | ||
|
||
## Usage | ||
|
||
**NOTE:** [The LaunchDarkly Vercel integration must be installed on our account.](https://vercel.com/integrations/launchdarkly) | ||
|
||
The following environment variables are required in order to use the default adapter: | ||
|
||
```sh | ||
export EDGE_CONFIG="https://edge-config.vercel.com/ecfg_abdc1234?token=xxx-xxx-xxx" # Provided by Vercel when connecting an Edge Config to the project | ||
export LD_CLIENT_SIDE_KEY="612376f91b8f5713a58777a1" | ||
export LD_PROJECT_SLUG="my-project" | ||
``` | ||
|
||
```ts | ||
import { launchDarkly, type LDContext } from '@flags-sdk/launchdarkly'; | ||
|
||
const identify = dedupe(async (): Promise<LDContext> => { | ||
return { | ||
key: 'user_123', | ||
}; | ||
}); | ||
|
||
export const showBanner = flag<boolean, LDContext>({ | ||
key: 'show-banner', | ||
identify, | ||
adapter: launchDarkly(), | ||
}); | ||
``` | ||
|
||
It's possible to create an adapter by using the `createLaunchDarklyAdapter` function: | ||
|
||
```ts | ||
import { createLaunchDarklyAdapter } from '@flags-sdk/launchdarkly'; | ||
|
||
const adapter = createLaunchDarklyAdapter({ | ||
ldProject: 'my-project', | ||
ldClientSideKey: '612376f91b8f5713a58777a1', | ||
edgeConfigConnectionString: process.env.EDGE_CONFIG, | ||
}); | ||
``` |