0.1.1 • Published 8 months ago

@flags-sdk/openfeature v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Flags SDK - OpenFeature Provider

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.

Setup

The OpenFeature provider is available in the @flags-sdk/openfeature module. Install it with

npm i @flags-sdk/openfeature @openfeature/server-sdk

The command also installs the @openfeature/server-sdk peer dependency, as the OpenFeature adapter depends on the OpenFeature Node.js SDK.

Provider Instance

Import the createOpenFeatureAdapter function from @flags-sdk/openfeature and create an adapter instance with your OpenFeature client.

For usage with regular providers, pass the client directly:

import { createOpenFeatureAdapter } from '@flags-sdk/openfeature';

OpenFeature.setProvider(new YourProviderOfChoice());
const openFeatureAdapter = createOpenFeatureAdapter(OpenFeature.getClient());

For usage with async providers, pass an init function, and return the client:

import { createOpenFeatureAdapter } from '@flags-sdk/openfeature';

// pass an init function, and return the client
const openFeatureAdapter = createOpenFeatureAdapter(async () => {
  const provider = new YourProviderOfChoice();
  await OpenFeature.setProviderAndWait(provider);
  return OpenFeature.getClient();
});

Documentation

Please check out the OpenFeature provider documentation for more information.

0.1.1

8 months ago

0.1.0

8 months ago