An (unofficial) Flagsmith Vue.js integration that uses Vue Composition API to dynamically update feature flags and traits in components. Compatible with Vue.js versions
2.7
and3
.
npm install flagsmith-vue flagsmith
Initialize the integration with the useFlagsmith
helper in your root/parent component:
import { useFlagsmith } from 'flagsmith-vue'
useFlagsmith(options)
For options
see Flagsmith initialization options.
Then you can access the flags, traits, loading status and the Flagsmith instance itself inside your child components:
import { useFlags, useTraits, useFlagsmithLoading } from 'flagsmith-vue'
const flags = useFlags(['flag1', 'flag2', ...])
const traits = useTraits(['trait1', 'trait2', ...])
const flagsmithLoading = useFlagsmithLoading()
const { setTraits } = useFlagsmithInstance()
Unless otherwise noted, all source code is licensed under the MIT License.
Copyright (c) 2024 Jochen Hörmann