
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@openfeature/env-var-provider
Advanced tools
The environment variable provider is a great way to start using OpenFeature. It doesn't require any infrastructure to setup or manage, and provides a simple way to gain experience with the core concepts of feature flagging. However, it doesn't support fea
The environment variable provider is a great way to start using OpenFeature. It doesn't require any infrastructure to setup or manage, and provides a simple way to gain experience with the core concepts of feature flagging. However, it doesn't support features such as dynamic updates at run-time or contextual flag evaluation. That's where feature flags become extremely powerful! Thankfully, the OpenFeature SDK supports basic providers such at this one, while making it simple to switch to a more powerful system when the time is right.
$ npm install @openfeature/env-var-provider
Required peer dependencies
$ npm install @openfeature/server-sdk
The environment variable provider uses environment variables to determine the value of a feature flag.
It supports booleans
, strings
, numbers
and objects
by attempting to interpret the value of an environment variable to the requested type.
The default value will be returned if the environment variable doesn't exist or the value can't be cast to the desired type.
// Register the environment variable provider globally
OpenFeature.setProvider(new EnvVarProvider());
Option name | Type | Default |
---|---|---|
disableConstantCase | boolean | false |
# Start a hypothetical application with the ENABLE_NEW_FEATURE environment variable
ENABLE_NEW_FEATURE=true node my-app.js
const client = OpenFeature.getClient();
client.getBooleanValue('enable-new-feature', false);
# Start a hypothetical application with the DIFFICULTY_MULTIPLIER environment variable
DIFFICULTY_MULTIPLIER=5 node my-app.js
const client = OpenFeature.getClient();
client.getNumberValue('difficulty-multiplier', 0);
# Start a hypothetical application with the WELCOME_MESSAGE environment variable
WELCOME_MESSAGE=yo node my-app.js
const client = OpenFeature.getClient();
client.getStringValue('welcome-message', 'hi');
# Start a hypothetical application with the PREFERRED_SDK environment variable
PREFERRED_SDK='{"name": "openfeature"}' node my-app.js
const client = OpenFeature.getClient();
client.getObjectValue('preferred-sdk', { name: 'OpenFeature' });
Run nx package providers-env-var
to build the library.
Run nx test providers-env-var
to execute the unit tests via Jest.
FAQs
The environment variable provider is a great way to start using OpenFeature. It doesn't require any infrastructure to setup or manage, and provides a simple way to gain experience with the core concepts of feature flagging. However, it doesn't support fea
The npm package @openfeature/env-var-provider receives a total of 2,474 weekly downloads. As such, @openfeature/env-var-provider popularity was classified as popular.
We found that @openfeature/env-var-provider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.