@flags-sdk/openfeature
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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.

Package Sidebar

Install

npm i @flags-sdk/openfeature

Weekly Downloads

1,537

Version

0.1.1

License

MIT

Unpacked Size

24.6 kB

Total Files

11

Last publish

Collaborators

  • dferber90
  • matt.straka
  • nick.tracey
  • vercel-release-bot