OpenFeature web Provider for feat feature flags. Bridges the sync evaluation cache from @feathq/web-sdk to OpenFeature's client-side API.
npm install @feathq/web-sdk @feathq/openfeature-web @openfeature/web-sdk@feathq/web-sdk and @openfeature/web-sdk are peer dependencies.
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); // sync- All
resolve*Evaluationmethods are synchronous: the underlying client caches the server-resolved flag values in a Map, refreshed onsetContextand on each poll / stream update. - Type coercion: a flag declared as
booleanreturns the default withTYPE_MISMATCHif asked for a string, etc. - Live updates: when a flag value flips (poll or stream), the provider emits
ProviderEvents.ConfigurationChanged, so the OpenFeature client and the@openfeature/react-sdkhooks re-render automatically. - Error codes: a missing flag resolves with
errorCode: FLAG_NOT_FOUND(andPROVIDER_NOT_READYbefore the client is ready); type mismatches keepTYPE_MISMATCH. OpenFeature.setContext(...)is the canonical way to change evaluation context; the provider'sonContextChangepropagates to the client.
MIT