• Public
  • Public/Protected
  • All

Module "launchdarkly-js-client-sdk"

This is the API reference for the LaunchDarkly SDK for browser JavaScript.

In typical usage, you will call initialize once at startup time to obtain an instance of LDClient, which provides access to all of the SDK's functionality.

For more information, see the SDK reference guide.


Type aliases


LDEvaluationReason: NonNullableLDEvaluationReason | null

Describes the reason that a flag evaluation produced a particular value. This is part of the LDEvaluationDetail object returned by LDClient.variationDetail.

Will be null when <a href="interfaces/_launchdarkly_js_client_sdk_.ldoptions.html#evaluationreasons">LDOptions.evaluationReasons</a> is false.


LDFlagValue: any

The types of values a feature flag can have.

Flags can have any JSON-serializable value.


Const version

version: string

The current version string of the SDK.



  • createConsoleLogger(minimumLevel: string): LDLogger
  • A basic implementation of logging that uses the global console object. This is used by default in the browser SDK. It sends messages of "debug", "info", "warn", or "error" level (if enable) to console.log(), console.info(), console.warn(), and console.error() respectively.

    To make LDClient use this logger, put it in the logger property of LDOptions.


    • minimumLevel: string

    Returns LDLogger


  • Creates an instance of the LaunchDarkly client.

    The client will begin attempting to connect to LaunchDarkly as soon as it is created. To determine when it is ready to use, call LDClient.waitForInitialization, or register an event listener for the "ready" event using LDClient.on.

    Note that you can either import this as a named export or as part of the default exports, although the latter is deprecated:

    // Preferred usage:
    import { initialize } from 'launchdarkly-js-client-sdk';
    const client = initialize(envKey, user, options);
    // Deprecated usage:
    import LaunchDarkly from 'launchdarkly-js-client-sdk';
    const client = LaunchDarkly.initialize(envKey, user, options);


    • envKey: string

      The environment ID.

    • user: LDUser

      The initial user properties. These can be changed later with LDClient.identify.

    • Optional options: LDOptions

      Optional configuration settings.

    Returns LDClient

    The new client instance.

Generated using TypeDoc