Simple client side toggle flags.


The FlagSwitcher component helps toggling the flags.


import flag from 'cozy-flags'

if (flag('my-feature')) {

The FlagSwitcher shows all flags in use and displays all flags in use.

import flag, { FlagSwitcher } from 'cozy-flags'

if (process.env.NODE_ENV !== 'production'
    && flag('switcher') === undefined) {
    flag('switcher', true) // set default flag in dev mode

const App = () => {
  return (
      { flag('switcher') && <FlagSwitcher /> }
      <MyApp />

Flags enabled at build time

It is possible to handle flags enabled at build time. Your app should just provide a global __ENABLED_FLAGS__ array with flag names that should be enabled. If such a global exists, cozy-flags will iterate on the array and enable all the flags it contains when it is imported.