Set up Node.js (client-side) SDK

Install and initialize the LaunchDarkly Node.js (client-side) SDK to start evaluating feature flags in your application.

Install the package

yarn add launchdarkly-node-client-sdk

Initialize the SDK

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

You can find your server-side SDK keys, mobile keys, and client-side ID on the SDK keys page under Settings.

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