Set up Vue SDK

Install the package

$yarn add launchdarkly-vue-client-sdk

Initialize the SDK

Vue SDK initialization
1// Add the code below to your main.js file.
2import { createApp } from 'vue';
3import App from './App.vue';
4import { LDPlugin } from 'launchdarkly-vue-client-sdk';
5
6const app = createApp(App);
7
8// A "context" is a data object representing users, devices, organizations, and other entities.
9const context = {
10 kind: 'user',
11 key: 'EXAMPLE_CONTEXT_KEY',
12 name: 'Sandy',
13};
14
15app.use(LDPlugin, {
16 clientSideID: 'YOUR_CLIENT_SIDE_ID',
17 context: context
18});
19
20app.mount('#app');

You can find your server-side SDK key, client-side ID, and mobile key in the “Resources” section of the help menu. Click the help icon at the bottom left corner of the LaunchDarkly UI, then choose SDK keys:

The SDK keys option in the help menu.

The SDK keys option in the help menu.

To learn more, read Initialize the client and context in the Vue SDK reference guide.