@configdirector/openfeature-web-provider
v1.10.1
Published
OpenFeature web provider for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.
Maintainers
Readme
ConfigDirector OpenFeature Web Provider
OpenFeature web provider SDK for ConfigDirector, remote config and feature flags with typed values, JSON Schema validation, and safe renames of live flags. Start free, no card required.
Install
npm install --save @configdirector/openfeature-web-provider @openfeature/web-sdkRetrieve a value
import { OpenFeature } from "@openfeature/web-sdk";
import { ConfigDirectorProvider } from "@configdirector/openfeature-web-provider";
await OpenFeature.setProviderAndWait(new ConfigDirectorProvider("YOUR-CLIENT-SDK-KEY"));
const client = OpenFeature.getClient();
const darkMode = client.getBooleanValue("dark-mode", false);Full details are in the official documentation.
Test your code
Tests of code that reads flags through OpenFeature swap the provider for the in-memory one the OpenFeature Web SDK ships, TypedInMemoryProvider (@openfeature/web-sdk 1.8 and newer), so the test controls the values and nothing from ConfigDirector is involved:
import { OpenFeature, TypedInMemoryProvider } from "@openfeature/web-sdk";
const provider = new TypedInMemoryProvider({
"new-checkout": { variants: { on: true, off: false }, defaultVariant: "on" },
});
await OpenFeature.setProviderAndWait(provider);
const client = OpenFeature.getClient();
expect(client.getBooleanValue("new-checkout", false)).toBe(true);
await provider.putConfiguration({
"new-checkout": { variants: { on: true, off: false }, defaultVariant: "off" },
});
expect(client.getBooleanValue("new-checkout", true)).toBe(false);Full details are in the testing section of the official documentation.
Documentation
Refer to the official documentation for the OpenFeature web provider.
There is also a quickstart guide for ConfigDirector and any of our SDKs.
