• Public
  • Public/Protected
  • All

LaunchDarkly Vue SDK (2.2.0)


Type aliases

LDPluginOptions: { clientSideID?: string; context?: LDContext; deferInitialization?: boolean; options?: LDOptions; streaming?: boolean; user?: LDContext }

Type declaration

  • Optional clientSideID?: string

    Indicates which LaunchDarkly project to use. Must be provided here or in a call to ldInit for the SDK to work.

  • Optional context?: LDContext

    A LaunchDarkly context object. If unspecified, an anonymous context with kind: 'user' will be created and used.

  • Optional deferInitialization?: boolean

    Defers initialization of the LaunchDarkly client until ldInit is called explicitly.



  • Optional options?: LDOptions

    Options to pass to the underlying javascript SDK.

  • Optional streaming?: boolean

    Enables or disables automatically subscribing to live updates to flags referenced using useLDFlag.



  • Optional user?: LDContext

    The user property will be removed in a future version, please update your code to use context instead.


LDPlugin: { install: any } = ...

Vue plugin wrapper for the LaunchDarkly JavaScript SDK.

If provided with a clientSideID will initialize the LaunchDarkly client automatically (unless deferInitialization is true).


LDPluginOptions for configuration options

Type declaration

  • install:function
    • Parameters

      Returns void

LD_CLIENT: InjectionKey<LDClient> = ...

Injection key used to retrieve LaunchDarkly client. Usage: const ldClient = inject(LD_CLIENT). Alternatively use useLDClient.

LD_FLAG: InjectionKey<<T>(flagKey: string, defaultFlagValue?: T) => Readonly<Ref<T>>> = ...

Injection key used to retrieve ldFlag function. Usage: const ldFlag = inject(LD_FLAG). Alternatively use useLDFlag.

LD_INIT: InjectionKey<(o?: LDPluginOptions) => [Readonly<Ref<boolean>>, LDClient]> = ...

Injection key used to retreive LaunchDarkly client initialization function. Usage: const ldInit = inject(LD_INIT). Alternatively use ldInit.

LD_READY: InjectionKey<Readonly<Ref<boolean>>> = ...

Injection key used to retrieve a boolean ref indicating if the LaunchDarkly client has finished initializing. Usage: const ldReady = inject(LD_READY). Alternatively use useLDReady.


  • Initializes the LaunchDarkly client. Uses Vue's inject API, and will only work if run inside a Vue setup hook or <script setup>.


    Returns [Readonly<Ref<boolean>>, LDClient]

  • useLDClient(): LDClient
  • useLDFlag<T>(flagKey: string, defaultValue?: T): Readonly<Ref<T>>
  • Evaluates a single feature flag. Automatically subscribes to streamed updates unless the streaming option was set to false. Uses Vue's inject API, so will only work if run inside a Vue setup hook or <script setup>.

    Type parameters

    • T

      Type of the flag's value. Can be inferred if a default value is provided.


    • flagKey: string

      Key of the feature flag to be evaluated.

    • Optional defaultValue: T

      Default value to be used while flag value loads, or if flag cannot be found.

    Returns Readonly<Ref<T>>

    Readonly ref to the flag's value.

  • useLDReady(): Readonly<Ref<boolean>>
  • Indicates if the LaunchDarkly client has finished initializing. Uses Vue's inject API, and will only work if run inside a Vue setup hook or <script setup>.

    Returns Readonly<Ref<boolean>>

    Readonly boolean reference indicating if the LaunchDarkly client has finished initializing.

Generated using TypeDoc