Node.js client for
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A Node.js client for interacting with This library is under active development and is likely to change frequently.


Run the following comands in a terminal:

$ npm install featureswitches


// Include and initialize FeatureSwitches
var featureswitches = require('featureswitches')('customer_api_key', 'environment_api_key', {options});

// Ensure that the API credentials are valid
featureswitches.authenticate().then(function(result) {
  if (result) {
    // Authentication Successful
  } else {
    // Authentication Failed

// Add a user
featureswitches.add_user('user_identifier', '[optional_customer_identifier]', '[optional_name]', '[optional_email'])
  .then(function(result) {
    // Result is boolean to indicate success

// Check if a feature is enabled
featureswitches.is_enabled('feature_key', '[optional_user_identifier]')
  .then(function(result) {
    if (result === true) {
      // Feature is enabled, do something
    } else {
      // Feature is disabled, do something else

Configuration Options

A few options are available to be tweaked if you so choose. The library makes use of a local cache to minimize requests back to the FeatureSwitches server. Additionally, a check it performed at an interval to automatically re-sync feature state when changes are made in the dashboard.

  cache_timeout: SECONDS, // optional, defaults to 300 seconds
  check_interval: SECONDS // optional, defaults to 10 seconds