Skip to content

Commit

Permalink
Document usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBitz committed Dec 16, 2024
1 parent f59327f commit 7f6a98b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/adapter-launchdarkly/README.md
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,
});
```

0 comments on commit 7f6a98b

Please sign in to comment.