@feathq/openfeature-web
v0.4.0
Published
OpenFeature web-sdk Provider for feat. Wraps @feathq/web-sdk to expose its sync cache through the OpenFeature client API.
Maintainers
Readme
feat OpenFeature Provider
OpenFeature web Provider for feat feature flags. Bridges the sync evaluation cache from @feathq/web-sdk to OpenFeature's client-side API.
Install
npm install @feathq/web-sdk @feathq/openfeature-web @openfeature/web-sdk@feathq/web-sdk and @openfeature/web-sdk are peer dependencies.
Usage
import { OpenFeature } from "@openfeature/web-sdk";
import { FeatWebClient } from "@feathq/web-sdk";
import { FeatWebProvider } from "@feathq/openfeature-web";
const featClient = new FeatWebClient({
apiKey: "feat_cs_…",
url: "https://data-01.feat.so", // optional; this is the default
});
await OpenFeature.setProviderAndWait(new FeatWebProvider(featClient));
await OpenFeature.setContext({ targetingKey: "user-123" });
const client = OpenFeature.getClient();
const enabled = client.getBooleanValue("checkout-v2", false); // syncNotes
- All
resolve*Evaluationmethods are synchronous: the underlying client pre-evaluates every flag into a Map onsetContextand on each datafile refresh. - Type coercion: a flag declared as
booleanreturns the default withTYPE_MISMATCHif asked for a string, etc. OpenFeature.setContext(...)is the canonical way to change evaluation context; the provider'sonContextChangepropagates to the client.
License
MIT
