react-tggl-client
v2.2.1
Published
Tggl React SDK
Downloads
1,754
Maintainers
Readme
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('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 { active } = useFlag('myFlag')
//...
}