The LaunchDarkly Vue Client SDK provides seamless integration of feature flags into Vue.js applications, specifically supporting Vue 3.2 and newer versions. As of `2.5.0`, it offers a robust solution for dynamically managing features, building upon the core LaunchDarkly JavaScript SDK. Key differentiators include first-class support for Vue's Composition API through reactive hooks (like `useFlags` and `useLDClient`) and a dedicated Vue plugin for easy initialization. The SDK sees frequent releases, typically every 1-3 months, ensuring compatibility with the latest Vue and LaunchDarkly platform features. It is designed for client-side environments, requiring a client-side ID for authentication and specific flag configurations to ensure availability.
npm install launchdarkly-vue-client-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the LaunchDarkly Vue SDK using `LDPlugin`, configure an `LDContext`, and then consume a feature flag reactively within a Vue component using the `useLDFlag` composable. It also shows how to access the underlying `LDClient` for custom event tracking.
Ensure you are using the 'Client-side ID' found in your LaunchDarkly project settings. Do not embed a server-side SDK key in client-side code.
Navigate to the flag's settings in the LaunchDarkly UI and ensure the 'Make this flag available to client-side SDKs' option is checked.
Update error handling for `waitForInitialization` to catch promise rejections if you are using a timeout. If no timeout is specified, the promise still waits indefinitely.
Ensure that any `metricValue` passed to the `track` method is a valid number. For non-numeric custom data, pass it within the `data` object of the event properties.
Upgrade your Vue project to Vue 3.2 or later. For Vue 2 projects, consider using the LaunchDarkly JavaScript SDK directly or community-developed wrappers compatible with Vue 2.
Replace all instances of `LDUser` with `LDContext` when defining your entities for flag evaluation. Ensure your context object explicitly defines a `kind` attribute.
Ensure your project is running Vue 3.2 or newer and that `app` is a valid Vue 3 application instance created with `createApp()`.
Verify that the `clientSideId` passed to `LDPlugin` is your correct LaunchDarkly Client-side ID (not an SDK key). Also, confirm that the feature flag in question has the 'Make this flag available to client-side SDKs' option checked in your LaunchDarkly dashboard.
When defining your `LDContext`, ensure you explicitly specify custom attributes or use type assertions if your context has a known structure. For example: `{ kind: 'user', key: 'example', email: 'test@example.com' } as LDContext & { email: string }`.Ensure all LaunchDarkly composables (`useLDFlag`, `useFlags`, `useLDClient`, etc.) are invoked directly within the `<script setup>` block of a Vue component or inside the `setup()` method of an options API component.