Vue quickstart
Install the Vue 3 plugin and pass the public client key from your environment. useFlag returns a reactive value that updates with flag changes.
npm install @dipswitch/sdk-vue
import { createDipswitch, useFlag } from '@dipswitch/sdk-vue'
import { createApp, defineComponent, h } from 'vue'
const dipswitch = createDipswitch({ clientKey: 'ds_client_...', user: { id: 'user-42' } })
const Checkout = defineComponent({
setup() {
const enabled = useFlag('new-checkout', false)
return () => h('p', enabled.value ? 'New checkout' : 'Checkout')
},
})
createApp(Checkout).use(dipswitch).mount('#app')
If a Vue Router guard depends on a flag, wait for dipswitch.client.ready and any in-flight identify call before making the decision. See Verify user identity for signed users.