Node.js Feature Flags

Feature flag / toggle management built for Node.js apps

Feature flags are a software development best practice of gating functionality. Functionality can be deployed “off”, then turned on via the feature flag, separate from deployment. With feature flags, you can manage the entire lifecycle of a feature.

LaunchDarkly's Node.js SDK lets you create and maintain Node feature flags across your entire application. You can centrally manage all of your feature flags, perform granular rollouts, and kill bad features without redeploying. All flag values are evaluated in-memory, so there is no latency for your users. New flag settings are streamed to the SDKs in real-time, so any changes to your flag rules will take effect almost immediately.

LaunchDarkly Dashboard & Feature Flag Manager
Click Image to Enlarge

Here are some product benefits of LaunchDarkly's Node.js Feature Flag SDK:

  • Real-time feature flags via a streaming API
  • In-memory flag evaluation with near zero latency
  • No external HTTP calls for flag values
  • Boolean & multivariate feature flags
  • Custom percentage rollouts and targeting rules
  • A/B testing
Click Image to Enlarge

Flag management benefits:

  • Audit log
  • Custom roles
  • Custom webhooks
  • Integrations for Slack and HipChat

Node.js Feature Flags

Let's create a Node feature flag for a "One Click Checkout"

1.Install the SDK with npm

Check out our open source Node SDK on GitHub or read through the reference documentation.

               
       npm install ldclient-node --save
                
              

2.Create a new LaunchDarkly client

               
       ldclient = LaunchDarkly.init("YOUR_SDK_KEY"))
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        var user = {
          "firstName": "Bob",
          "lastName": "Loblaw",
          "key": "bob@example.com",
          "custom": {
            "groups": "beta_testers"
          }
        };

        ldclient.variation("one_click_checkout", user, false, function(err, showFeature) {
          if (showFeature) {
            // application code to show One Click Checkout
            console.log("Showing your feature to " + user.key );
          } else {
            // the code to run if the feature is off
            console.log("Not showing your feature to " + user.key);
          }
        });
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.


Create your own Node.js feature flags in minutes.
How It Works