@openfeature/js-sdk v1.0.99-experimental-bfb4a41e0a80281da05013340716f4fe60910f47
OpenFeature SDK for JavaScript
This is the JavaScript implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating feature flags.
We support multiple data types for flags (numbers, strings, booleans, objects) as well as hooks, which can alter the lifecycle of a flag evaluation.
This library is intended to be used in server-side contexts and has only experimental support for web usage.
Installation
npm install @openfeature/js-sdkor
yarn add @openfeature/js-sdkUsage
import { OpenFeature } from '@openfeature/js-sdk';
// configure a provider
OpenFeature.setProvider(new YourProviderOfChoice());
// create a client
const client = OpenFeature.getClient('my-app');
// get a bool value
const boolValue = await client.getBooleanValue('boolFlag', false);
// get a string value
const stringValue = await client.getStringValue('stringFlag', 'default');
// get an numeric value
const numberValue = await client.getNumberValue('intFlag', 1);
// get an object value
const object = await client.getObjectValue<MyObject>('objectFlag', {});
// add a value to the invocation context
const context: EvaluationContext = {
myInvocationKey: 'myInvocationValue',
};
const contextAwareValue = await client.getBooleanValue('boolFlag', false, context);For complete documentation, visit: https://docs.openfeature.dev/docs/category/concepts
Contributing
See CONTRIBUTING.md for details on how to contribute to the OpenFeature project.
Our community meetings are held regularly and open to everyone. Check the OpenFeature community calendar for specific dates and for the Zoom meeting links.
Thanks so much to our contributors.
Made with contrib.rocks.