SDKs & API

React SDK

The React SDK provides hooks and a provider for reading flags with live updates. Bundle size is under 4 kB gzipped.

Installation

$ npm install @flagfish/react

useFlag(key, fallback)

Returns the live value for a flag and re-renders when it changes.

import { useFlag } from '@flagfish/react';

function Banner() {
  const show = useFlag('holiday-banner', false);
  return show ? <Promo /> : null;
}

Identifying users

Pass a user context to the provider so targeting rules can evaluate.

<FlagFishProvider
  clientKey="ff_live_..."
  user={{ key: 'user_8f2', plan: 'pro' }}>
  <App />
</FlagFishProvider>
Next Node.js SDK →