node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


nconf & express based features flags

Neff is simple express middleware for handling feature flags.

The standard way to use neff on the client & the server side is to check for enabled features using the isEnabled() API.

var users = 500;
var moreUsers = neff.isEnabled("moreUsers");
if (moreUsers) {

To get started with neff you'll want to make sure you call neff, passing it an an object with feature names and either true or false values.

var neff = require("neff")({
    "feature1": true,
    "feature2": false

If you'd like to utilize NConf for this, you can reference an NConf JSON file and my config looks like this:

    "feature1": true,
    "feature2": false

Then pass the config object for the features to neff:

var neff = require("neff")(nconf.get('features'));

The first thing it allows you to do is access feature flags directly in your template such as (dust syntax):


This route is only available when the feature flag is enabled. Otherwise the user would see a server error page.

var neff = require("neff");
app.get("/myhidden/route", neff.limit("feature1"), function(req, res) {
   res.send("You have found feature1!");

It also provides a string of class names you can insert into your <body> (dust syntax):

<body class="{featureClasses}">

The output prepends feature- to the classname, so you might see something like <body class="feature-feature1"> with the config above. Only enabled features show up in the string.

Make sure your features are declared on your DOM like so:

<body class="feature-feature1 feature-feature2">

Once you've done that you can take advantage of the flags in 2 ways.

/* Create a block that's hidden by default */
.my-cool-block {
    display: none;
/* Display that block when your flag is present */
.feature-feature1 .my-cool-block {
    display: block;
define(["neff"], function(neff) {
    if (neff.isEnabled("feature1")) {
        /* .. */

Inspired heavily by