@groundcontrolsh/react
v0.3.0
Published
GroundControl TypeScript SDK for React
Downloads
4
Readme
GroundControl
React SDK for GroundControl.
Installing
With NPM
npm i @groundcontrolsh/groundcontrol @groundcontrolsh/react
With yarn
yarn add @groundcontrolsh/groundcontrol @groundcontrolsh/react
Usage
import { GroundControlClient } from "@groundcontrolsh/groundcontrol";
import { GroundControlProvider, useFeatureFlag } from "@groundcontrolsh/react";
// In your top-most component tree
const client = new GroundControlClient({
projectId: "YOUR_PROJECT_ID",
apiKey: "YOUR_API_KEY",
cache: 60, // Optional. For how long results are cached in seconds. Defaults to not caching.
});
function App() {
// The cache prop defines for how long results are cached in seconds. Defaults to not caching.
return <GroundControlProvider client={client}>...</GroundControlProvider>;
}
// In your components
function MyComponent() {
const isEnabled = useFeatureFlag("flag-name");
const isEnabledForActor = useFeatureFlag("flag-name", {
actors: ["actor1234"],
});
// ...
}