Skip to main content
Version: 2.0.0

Node.js - 5 Minute Test

Get Featureflow running in your Node.js application in under 5 minutes.

Prerequisites

If you haven't already, create a free Featureflow account. New accounts include a default project with test and production environments, plus an example feature.

1. Clone the Example Project

git clone https://github.com/featureflow/featureflow-fiveminute-node
cd featureflow-fiveminute-node
npm install

2. Add Your API Key

Edit helloworld.js and replace the placeholder with your Server Environment API Key. You can find this under the API Keys link on your project page.

const featureflow = new Featureflow.Client({ apiKey: 'srv-env-YOUR_API_KEY' });

featureflow.ready(function() {
if (featureflow.evaluate('example-feature').isOn()) {
console.log('The variant is on!');
} else {
console.log('The variant is not on!');
}
});

3. Run the Program

node helloworld.js

With the default configuration, you should see:

The variant is not on!

4. Toggle the Feature

In the Featureflow dashboard, enable the example-feature in your environment:

Feature Targeting

Run the program again:

node helloworld.js

Now you should see:

The variant is on!

Congratulations! You've successfully integrated Featureflow.

important

The Featureflow client must be a singleton. In production applications, create the client once at startup. See the Express example for a real-world implementation.

Next Steps