Skip to content

Commit fe72a22

Browse files
authored
enhance README (#101)
1 parent 9133853 commit fe72a22

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.changeset/quiet-ants-drive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@flags-sdk/openfeature': patch
3+
---
4+
5+
enhance README
+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Flags SDK - OpenFeature Provider
22

3+
OpenFeature is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution. The Flags SDK OpenFeature adapter allows you to use the Flags SDK with any OpenFeature provider.
4+
5+
## Setup
6+
7+
The OpenFeature provider is available in the `@flags-sdk/openfeature` module. Install it with
8+
39
```sh
410
npm i @flags-sdk/openfeature @openfeature/server-sdk
511
```
12+
13+
The command also installs the @openfeature/server-sdk peer dependency, as the OpenFeature adapter depends on the OpenFeature Node.js SDK.
14+
15+
## Provider Instance
16+
17+
Import the `createOpenFeatureAdapter` function from `@flags-sdk/openfeature` and create an adapter instance with your OpenFeature client.
18+
19+
For usage with regular providers, pass the client directly:
20+
21+
```ts
22+
import { createOpenFeatureAdapter } from '@flags-sdk/openfeature';
23+
24+
OpenFeature.setProvider(new YourProviderOfChoice());
25+
const openFeatureAdapter = createOpenFeatureAdapter(OpenFeature.getClient());
26+
```
27+
28+
For usage with async providers, pass an init function, and return the client:
29+
30+
```ts
31+
import { createOpenFeatureAdapter } from '@flags-sdk/openfeature';
32+
33+
// pass an init function, and return the client
34+
const openFeatureAdapter = createOpenFeatureAdapter(async () => {
35+
const provider = new YourProviderOfChoice();
36+
await OpenFeature.setProviderAndWait(provider);
37+
return OpenFeature.getClient();
38+
});
39+
```
40+
41+
## Documentation
42+
43+
Please check out the [OpenFeature provider documentation](https://flags-sdk.dev/docs/api-reference/adapters/openfeature) for more information.

0 commit comments

Comments
 (0)