Skip to content

jhoermann/flagsmith-vue

Repository files navigation

flagsmith-vue

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 and 3.

npm GitHub GitHub tests workflow Codacy Code Quality Codacy Coverage

Installation

npm install flagsmith-vue flagsmith

Usage

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()

License

Unless otherwise noted, all source code is licensed under the MIT License.
Copyright (c) 2024 Jochen Hörmann