• Public
  • Public/Protected
  • All

LaunchDarkly Client-Side SDK for React Native (6.0.0)

This is the API reference for the LaunchDarkly Client-Side SDK for React Native.

In typical usage, you will instantiate LDClient and then call configure once at startup time to set up your connection to LaunchDarkly.

For more information, see the SDK reference guide.


Type aliases

LDConfig: { allUserAttributesPrivate?: boolean; autoAliasingOptOut?: boolean; backgroundPollingIntervalMillis?: number; connectionTimeoutMillis?: number; debugMode?: boolean; diagnosticOptOut?: boolean; diagnosticRecordingIntervalMillis?: number; disableBackgroundUpdating?: boolean; evaluationReasons?: boolean; eventsCapacity?: number; eventsFlushIntervalMillis?: number; eventsUri?: string; inlineUsersInEvents?: boolean; maxCachedUsers?: number; mobileKey: string; offline?: boolean; pollUri?: string; pollingIntervalMillis?: number; privateAttributeNames?: string[]; secondaryMobileKeys?: Record<string, string>; stream?: boolean; streamUri?: string; useReport?: boolean }

Configuration options for the LaunchDarkly React Native SDK.

Type declaration

  • Optional allUserAttributesPrivate?: boolean

    Whether to treat all user attributes as private for event reporting for all users. The SDK will not include private attribute values in analytics events, but private attribute names will be sent. The default is false.

  • Optional autoAliasingOptOut?: boolean

    Whether to disable the automatic sending of an alias event when LDClient.identify is called with a non-anonymous user when the previous user is anonymous.

    The default value is false.

  • Optional backgroundPollingIntervalMillis?: number

    The interval by which the SDK polls for flag updates when the application is in the background.

    The default value is 3600000ms (1 hour).

  • Optional connectionTimeoutMillis?: number

    The timeout interval for connecting to LaunchDarkly for flag requests and event reports.

    The default value is 10000ms (10 seconds).

  • Optional debugMode?: boolean

    Controls information logged to the console, and modifying some setting ranges to facilitate debugging.

    This setting is only used when running in iOS. In Android this setting is ignored.

    The default value is false.

  • Optional diagnosticOptOut?: boolean

    Setting for whether sending diagnostic data about the SDK is disabled. The default is false.

  • Optional diagnosticRecordingIntervalMillis?: number

    The time interval between sending periodic diagnostic data. The default is 900000 (15 minutes).

  • Optional disableBackgroundUpdating?: boolean

    Whether or not the SDK should attempt to check for flag updates while the application runs in the background.

    If this is true, the client will periodically poll for updates while in the background; if false, the SDK will not attempt to receive updates while the app is backgrounded.

    The default value is false.

  • Optional evaluationReasons?: boolean

    Whether LaunchDarkly should provide additional information about how flag values were calculated.

    The additional information will then be available through the client's LDClient.*VariationDetail methods. Since this increases the size of network requests, such information is not sent unless you set this option to true.

  • Optional eventsCapacity?: number

    The capacity of the analytics events queue.

    The client buffers up to this many events in memory before flushing. If the capacity is exceeded before the queue is flushed, events will be discarded. Increasing the capacity means that events are less likely to be discarded, at the cost of consuming more memory. Note that in regular usage flag evaluations do not produce individual events, only summary counts, so you only need a large capacity if you are generating a large number of click, pageview, or identify events (or if you are using the event debugger).

    The default value is 100.

  • Optional eventsFlushIntervalMillis?: number

    The interval in between flushes of the analytics events queue, in milliseconds.

    The default value is 30000ms (30 seconds).

  • Optional eventsUri?: string

    The base URI for the LaunchDarkly events server.

    Most users should use the default value.

  • Optional inlineUsersInEvents?: boolean

    Whether to include full user details in every analytics event.

    The default is false: events will only include the user key, except for one "identify" event that provides the full details for the user.

  • Optional maxCachedUsers?: number

    Setting for the maximum number of locally cached users. Default is 5 users.

  • mobileKey: string

    The mobile SDK key associated with your LaunchDarkly environment.

    This field is required as the React Native SDK will use this value to uniquely identify your LaunchDarkly account.

  • Optional offline?: boolean

    Disables all network calls from the LaunchDarkly SDK.

    This can also be specified after the client has been created, using LDClient.setOffline().

    The default value is true (the client will make network calls).

  • Optional pollUri?: string

    The base URI for the LaunchDarkly polling server.

    Most users should use the default value.

  • Optional pollingIntervalMillis?: number

    The interval by which the SDK polls for flag updates when the application is in the foreground. This property is only used if is the streaming connection is disabled.

    The default value is 300000ms (5 min).

  • Optional privateAttributeNames?: string[]

    The names of user attributes that should be marked as private, and not sent to LaunchDarkly in analytics events.

    You can also specify this on a per-user basis with [[LDUser.privateAttributeNames]].

  • Optional secondaryMobileKeys?: Record<string, string>

    The mapping of environment names as keys to mobile keys for each environment as values.

  • Optional stream?: boolean

    Whether or not to open a streaming connection to LaunchDarkly for live flag updates.

    If this is true, the client will always attempt to maintain a streaming connection; if false, it never will.

    The default value is true.

  • Optional streamUri?: string

    The base URI for the LaunchDarkly streaming server.

    Most users should use the default value.

  • Optional useReport?: boolean

    Whether or not to use the REPORT verb to fetch flag settings.

    If this is true, flag settings will be fetched with a REPORT request including a JSON entity body with the user object.

    Otherwise (by default) a GET request will be issued with the user passed as a base64 URL-encoded path parameter.

    Do not use unless advised by LaunchDarkly.

LDEvaluationDetail<T>: { reason: LDEvaluationReason; value: T; variationIndex?: number }

An object that combines the result of a feature flag evaluation with information about how it was calculated.

This is the result of calling one of the LDClient.*VariationDetail methods.

For more information, see the documentation.

Type parameters

  • T

    The type of flag being evaluated.

Type declaration

  • reason: LDEvaluationReason

    An object describing the main factor that influenced the flag evaluation value.

  • value: T

    The result of the flag evaluation. This will be either one of the flag's variations or the default value that was passed to the variation detail function.

  • Optional variationIndex?: number

    The index of the returned value within the flag's list of variations, e.g. 0 for the first variation-- or null if the default value was returned.

Describes the reason that a flag evaluation produced a particular value. This is part of the LDEvaluationDetail object returned by the variation detail methods.

LDEvaluationReasonError: { errorKind: LDEvaluationReasonErrorKind; kind: "ERROR" }

The flag could not be evaluated, so the default value was returned.

Type declaration

  • errorKind: LDEvaluationReasonErrorKind

    The kind of error which occurred.

    Kinds of errors include:

    • 'CLIENT_NOT_READY': The client is not able to establish a connection to LaunchDarkly yet. If there is a persistent feature store, the store does not yet contain flag data.
    • 'FLAG_NOT_FOUND': The flag key did not match any known flag.
    • 'USER_NOT_SPECIFIED': The user object or user key was not provided.
    • 'MALFORMED_FLAG': There was an internal inconsistency in the flag data. For example, a rule specified a nonexistent variation. This is an unusual condition that might require assistance from LaunchDarkly's Support team.
    • 'WRONG_TYPE': The application code requested the flag value with a different data type than it actually is. For example, the code asked for a boolean when the flag type is actually a string.
    • 'EXCEPTION': An unexpected error stopped flag evaluation. This could happen if you are using a persistent feature store and the database stops working. When this happens, the SDK always prints the specific error to the log.
  • kind: "ERROR"
LDEvaluationReasonFallthrough: { kind: "FALLTHROUGH" }

The flag is on, but the user did not match any targets or rules, so it returned the value that appears on the dashboard under "Default rule."

Type declaration

  • kind: "FALLTHROUGH"
LDEvaluationReasonOff: { kind: "OFF" }

The flag is off and therefore returned its configured off value.

Type declaration

  • kind: "OFF"
LDEvaluationReasonPrerequisiteFailed: { kind: "PREREQUISITE_FAILED"; prerequisiteKey: string }

The flag had at least one prerequisite flag that either was off or did not return the desired variation. Because of this, the flag returned its "off" value.

Type declaration

  • prerequisiteKey: string

    The key of the prerequisite flag that failed.

LDEvaluationReasonRuleMatch: { kind: "RULE_MATCH"; ruleId: string; ruleIndex: number }

The user who encountered the flag matched one of the flag's rules.

Type declaration

  • kind: "RULE_MATCH"
  • ruleId: string

    The rule's unique identifier, which stays the same even if you rearrange the order of the rules.

  • ruleIndex: number

    The positional index of the matched rule (0 for the first rule).

LDEvaluationReasonTargetMatch: { kind: "TARGET_MATCH" }

The user key was specifically targeted for this flag in the "Target individual users" section.

Type declaration

  • kind: "TARGET_MATCH"
LDUser: { anonymous?: boolean; avatar?: string; country?: string; custom?: {}; email?: string; firstName?: string; ip?: string; key?: string; lastName?: string; name?: string; privateAttributeNames?: string[]; secondary?: string }

A LaunchDarkly user object.

Type declaration

  • Optional anonymous?: boolean

    Whether to show the user on the Users page in LaunchDarkly.

    The default value is false.

  • Optional avatar?: string

    The avatar associated with the user.

  • Optional country?: string

    The country associated with the user.

  • Optional custom?: {}

    Any additional attributes associated with the user.

    • [key: string]: any
  • Optional email?: string

    The user's email address.

  • Optional firstName?: string

    The user's first name.

  • Optional ip?: string

    The IP address associated with the user.

  • Optional key?: string

    A unique string identifying a user.

    If this value is not provided, a key will be generated automatically and the anonymous property of the user will be set to true. The SDK will provide a key value that is non-identifying, unique between devices, but usually stable between launches of the application on a specific device. The SDK cannot guarantee the value will not change between launches as the platform may change identifiers provided to the application or remove the locally stored application data.

  • Optional lastName?: string

    The user's last name.

  • Optional name?: string

    The user's name.

    You can search for users on the User page by name.

  • Optional privateAttributeNames?: string[]

    Specifies a list of attribute names (either built-in or custom) which should be marked as private, and not sent to LaunchDarkly in analytics events.

  • Optional secondary?: string

    The secondary key for the user. See the documentation for more information on it's use for percentage rollout bucketing.

Generated using TypeDoc