Set up Node.js (client-side) SDK

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
9const client = LaunchDarkly.initialize('YOUR_CLIENT_SIDE_ID', context);
10
11try {
12 await client.waitForInitialization(5);
13 // Initialization succeeded
14} catch (err) {
15 // Initialization failed or did not complete before timeout
16}

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.