Set up Node.js (server-side) SDK

LaunchDarkly onboarding is not available in federal environments
To learn more, read LaunchDarkly in federal environments.

Install the package

$yarn add @launchdarkly/node-server-sdk

Initialize the SDK

Node.js (server-side) SDK initialization
1import * as LaunchDarkly from '@launchdarkly/node-server-sdk';
2
3// This is your LaunchDarkly SDK key.
4// Never hardcode your SDK key in production.
5const client = LaunchDarkly.init('YOUR_SDK_KEY');
6
7client.once('ready', function () {
8 // For onboarding purposes only we flush events as soon as
9 // possible so we quickly detect your connection.
10 // You don't have to do this in practice because events are automatically flushed.
11 client.flush();
12 console.log('SDK successfully initialized!');
13});

You can find your server-side SDK key, client-side ID, and mobile key in the “Resources” section of the help menu. Click the help icon at the bottom left corner of the LaunchDarkly UI, then choose SDK keys:

The SDK keys option in the help menu.

The SDK keys option in the help menu.

To learn more, read Initialize the client in the Node.js (server-side) SDK reference guide.