• 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, context, options);
    
    // Deprecated usage:
    import LaunchDarkly from 'launchdarkly-js-client-sdk';
    const client = LaunchDarkly.initialize(envKey, user, options);
    

    Parameters

    • envKey: string

      The environment ID.

    • context: LDContext

      The initial context properties. These can be changed later with [[LDClient.identify]].

    • Optionaloptions: LDOptions

      Optional configuration settings.

    Returns LDClient

    The new client instance.