1. Install the SDK
npm i react-tggl-client
2. Create the client
Wrap your app in a provider to make the client available anywhere in your app.
import { TgglClient, TgglProvider } from 'react-tggl-client'
const client = new TgglClient('YOUR_API_KEY')
const App = () => {
return (
<TgglProvider client={client}>
{/*...*/}
</TgglProvider>
)
}
3. Start using feature flags
import { useFlag } from 'react-tggl-client'
const MyComponent = () => {
const { active } = useFlag('myFlag')
//...
}
Written in Typescript
Types are automatically pulled from the API and are available in your IDE. Nor more guessing what the return type of a flag is, all typos are picked-up by your IDE and CI build process.