Set up Node.js (client-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-client-sdk

Initialize the SDK

Node.js (client-side) SDK initialization
1import * as LaunchDarkly from 'launchdarkly-node-client-sdk';
2
3// A "context" is a data object representing users, devices, organizations, and other entities.
4const context = {
5 kind: 'user',
6 key: 'EXAMPLE_CONTEXT_KEY',
7};
8
9// This is your client-side ID.
10const client = LaunchDarkly.initialize('YOUR_CLIENT_SIDE_ID', context);
11
12try {
13 await client.waitForInitialization(5);
14 // Initialization succeeded
15} catch (err) {
16 // Initialization failed or did not complete before timeout
17}

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 (client-side) SDK reference guide.