OpenFeature
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.
If there is a native Flags SDK adapter for your provider, we recommend using that instead. Native Flags SDK adapters finely tune the SDK for your flag provider, optionally integrate with Edge Config and Flags Explorer, and are configured for Edge Runtime compatibility where possible. See available adapters
The @flags-sdk/openfeature
package provides an adapter for loading flags from OpenFeature.
Learn more about Adapters
Clone the OpenFeature template
Setup
The OpenFeature provider is available in the @flags-sdk/openfeature
module. Install it with
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:
For usage with async providers, pass an init function, and return the client:
Option key | Type | Description |
---|---|---|
client | Client | (() => Promise<Client>) | OpenFeature client |
Identify Users
OpenFeature relies on an Evaluation Context object to evaluate the flags for a given request.
Use the identify
function to determine the Evaluation Context.
Learn more about dedupe
Learn more about identify
Methods
The OpenFeature adapter provides methods for evaluating flags.
booleanValue
identify
must return the Evaluation Context.defaultValue
must be provided when used with the OpenFeature adapter.
stringValue
identify
must return the Evaluation Context.defaultValue
must be provided when used with the OpenFeature adapter.
numberValue
identify
must return the Evaluation Context.defaultValue
must be provided when used with the OpenFeature adapter.
objectValue
identify
must return the Evaluation Context.defaultValue
must be provided when used with the OpenFeature adapter.
client
When the openFeatureAdapter
was created synchronously, this contains the OpenFeature client.
When the openFeatureAdapter
was created asynchronously, this is an async function which returns the OpenFeature client returned by the init
function.
Edge Config
The OpenFeature adapter does not integrate with Edge Config directly.
We recommend using a native Flags SDK adapter for your provider instead of using the OpenFeature adapter. Native Flags SDK adapters finely tune the SDK for your flag provider, optionally integrate with Edge Config and Flags Explorer, and are configured for Edge Runtime compatibility where possible. See available adapters.
If no native Flags SDK adapter is available, your OpenFeature provider might still allow you to configure Edge Config integration.
Flags Explorer
The Flags Explorer is a tool for viewing and overriding flags.
All feature flags using the Flags SDK can be overwritten by the Flags Explorer.
To make the Flags Explorer aware of your OpenFeature flags, you need to provide a route which the Flags Explorer will load your flags metadata from.
Caveats
Edge Runtime compatibility
The OpenFeature provider of your choice may not be compatible with Edge Runtime, which can prevent usage in Edge Middleware and Edge Functions. This depends on the provider you use OpenFeature with.
Flags Explorer metadata
Due to limitations in the OpenFeature specification, the @flags-sdk/openfeature
adapter is not capable of providing additional metadata like descriptions and available options to the Flags Explorer. Flags Explorer can still display the descriptions and options you define when declaring feature flags in code.
Read More
Read more about OpenFeature, Flags SDK, and the OpenFeature Node.js SDK.
Learn more about Adapters
Clone the OpenFeature template
Learn more about the Flags Explorer
Learn more about the OpenFeature Node.js SDK