npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openfeature/flagsmith-provider

v0.1.2

Published

This is an OpenFeature provider implementation for using [Flagsmith](https://flagsmith.com), a managed feature flag and remote config platform for Node.js applications.

Readme

Flagsmith Provider

This is an OpenFeature provider implementation for using Flagsmith, a managed feature flag and remote config platform for Node.js applications.

Installation

npm install @openfeature/flagsmith-provider @openfeature/server-sdk@^1.19 flagsmith-nodejs@^6.1

Usage

The Flagsmith provider uses the Flagsmith Node.js SDK.

It can be created by passing a configured Flagsmith client instance to the FlagsmithOpenFeatureProvider constructor.

Example using the default configuration

import { OpenFeature } from '@openfeature/server-sdk';
import { FlagsmithOpenFeatureProvider } from '@openfeature/flagsmith-provider';
import { Flagsmith } from 'flagsmith-nodejs';

// Create the Flagsmith client
const flagsmith = new Flagsmith({
  environmentKey: '<your_environment_key>',
});

// Create and set the provider
const provider = new FlagsmithOpenFeatureProvider(flagsmith);
await OpenFeature.setProviderAndWait(provider);

// Obtain a client instance and evaluate feature flags
const client = OpenFeature.getClient();

const value = await client.getBooleanValue('my-flag', false, { targetingKey: 'user-123' });
console.log(`my-flag: ${value}`);

// On application shutdown, clean up the OpenFeature provider
await OpenFeature.clearProviders();

Example using custom configuration

import { OpenFeature } from '@openfeature/server-sdk';
import FlagsmithOpenFeatureProvider from '@openfeature/flagsmith-provider';
import Flagsmith from 'flagsmith-nodejs';

// Create the Flagsmith client with custom options
const flagsmith = new Flagsmith({
  environmentKey: '<your_environment_key>',
  enableLocalEvaluation: true,
  retries: 3,
});

// Create the provider with custom configuration
const provider = new FlagsmithOpenFeatureProvider(flagsmith, {
  returnValueForDisabledFlags: true,
  useFlagsmithDefaults: true,
  useBooleanConfigValue: false,
});

await OpenFeature.setProviderAndWait(provider);

// ...

Configuration Options

The provider accepts the following configuration options:

| Option | Type | Default | Description | | ----------------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | returnValueForDisabledFlags | boolean | false | If true, returns flag values even when disabled. If false, throws error for disabled flags (except boolean flags which return false with reason DISABLED when useBooleanConfigValue=false) | | useFlagsmithDefaults | boolean | false | If true, allows using Flagsmith default flag values. If false, returns default value with error code for missing flags | | useBooleanConfigValue | boolean | false | If true, returns flag.value for boolean flags. If false, returns flag.enabled |

Evaluation Context

The OpenFeature Evaluation Context is mapped to Flagsmith's identity and traits system.

Identity Resolution

  • If targetingKey is provided in the evaluation context, the provider will use getIdentityFlags() to retrieve flags for that specific identity
  • If no targetingKey is provided, the provider will use getEnvironmentFlags() to retrieve environment-level flags

Traits

The traits field in the evaluation context is passed directly to Flagsmith as user traits for targeting and segmentation.

Example

const evaluationContext = {
  targetingKey: 'user-123',
  traits: {
    email: '[email protected]',
    plan: 'premium',
    age: 25,
  },
};

const value = await client.getBooleanValue('premium-feature', false, evaluationContext);

Flag Value Types

The provider supports all OpenFeature flag value types:

  • Boolean: Returns flag.enabled by default, or flag.value if useBooleanConfigValue is true
  • String: Returns the flag value as-is if it's a string
  • Number: Attempts to parse the flag value as a number
  • Object: Attempts to parse the flag value as JSON

Error Handling

The provider handles various error scenarios:

  • Flag Not Found: Returns default value with FLAG_NOT_FOUND error code
  • Type Mismatch: Returns default value with TYPE_MISMATCH error code if flag value cannot be converted to requested type
  • Disabled Flags:
    – For boolean flags with useBooleanConfigValue=false: returns false with reason DISABLED
    – For other flags: throws GeneralError unless returnValueForDisabledFlags is true
  • General Errors: Throws GeneralError for client communication issues

Building

Run:

nx package providers-flagsmith

to build the library.

Running unit tests

Run:

npx nx run providers-flagsmith:test

to execute the unit tests via Jest.