This package provides the LaunchDarkly Client-Side SDK for Node.js environments, specifically designed for applications deployed to an end-user, such as desktop apps or smart devices, rather than multi-user server-side systems. It enables developers to integrate feature flagging capabilities into their Node.js client applications, allowing for controlled feature rollouts, A/B testing, and dynamic configuration. The current stable version is 3.3.1. The SDK maintains an active release cadence, with updates typically every few months, addressing bug fixes, performance improvements, and new features like client-side prerequisite events and enhanced error handling. A key differentiator is its explicit focus on single-user contexts, contrasting with the separate server-side SDK for multi-user applications, and its evolution to support custom contexts over the older 'users' concept in version 3.0.0.
npm install launchdarkly-node-client-sdkVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the LaunchDarkly client with a context, wait for initialization, evaluate a boolean and string feature flag, and track a custom event.
Refactor all `user` objects to conform to the `LDContext` interface. For single users, `context` has a `kind` attribute set to `'user'` and a `key` property. Consult the migration guide for a full list of changes.
For server-side Node.js applications, use `launchdarkly-node-server-sdk` instead. If you need a client-side SDK in a browser, use `launchdarkly-js-client-sdk`.
Consider adding a timeout to `waitForInitialization` to prevent your application from hanging indefinitely during SDK initialization failure or network issues. Recommended timeouts for client-side SDKs are 100-500ms.
Prefer providing a unique `key` for your `LDContext` objects to ensure consistent user identification and accurate flag targeting, unless explicitly designing for anonymous users with generated keys.
If using ES Modules (TypeScript/modern Node.js), use `import { initialize } from 'launchdarkly-node-client-sdk';`. If using CommonJS, use `const { initialize } = require('launchdarkly-node-client-sdk');` or `const LaunchDarkly = require('launchdarkly-node-client-sdk');` and then `LaunchDarkly.initialize()`.Ensure `await client.waitForInitialization()` (with an optional timeout) is called and resolved before attempting to evaluate feature flags. This guarantees the SDK has fetched flag configurations.
Verify that you are using a *client-side* SDK key obtained from your LaunchDarkly project settings. Client-side keys are designed to be embedded in client applications and usually start with `mob-` or `client-`. Never use a server-side SDK key (which is a secret) in client-side code.
No dependency data recorded yet.