-
Install the Node.js SDK with
npmnpm install ldclient-node --save -
Require the LaunchDarkly client:
var LaunchDarkly = require('ldclient-node'); -
Create a new LDClient with your API key:
ld_client = LaunchDarkly.init("YOUR API KEY")
-
Create a new feature flag on your dashboard
-
In your application code, use the feature's key to check wthether the flag is on for each user:
ld_client.get_flag("your.flag.key", {"key" : "user@test.com"}, false, function(show_feature) { if (show_feature) { # application code to show the feature } else { # the code to run if the feature is off } });