npm.io
4.0.1 • Published 10 months ago

react-tggl-client

Licence
ISC
Version
4.0.1
Deps
1
Size
30 kB
Vulns
0
Weekly
0

Tggl Logo

Tggl React SDK

The React SDK can be used to evaluate flags and report usage to the Tggl API or a proxy.

Website Documentation NPM Videos

GitHub Workflow Status (with event) Coveralls branch npm

Usage

Install the dependency:

npm i react-tggl-client

Add the provider to your app:

import { TgglClient, TgglProvider } from 'react-tggl-client'

// Instanciate it outside of your component
const client = new TgglClient({ apiKey: 'YOUR_API_KEY' })

const App = () => {
  return (
    <TgglProvider client={client}>
      {/*...*/}
    </TgglProvider>
  )
}

Use the hook to evaluate flags:

import { useFlag } from 'react-tggl-client'
 
const MyComponent = () => {
  const value = useFlag('myFlag', 'Varation A')
 
  //...
}

Keywords