Skip to main content

1. Create a flag

  1. Navigate to your project in the OmniFlags dashboard.
  2. Click New flag. Set the key (e.g. charge-delivery-fee), type (Boolean), and category (Release).
  3. In the Targeting tab, enable the flag and set rollout to 100%.
Flag keys are scoped to their project. The SDK key you reference in code is {projectKey}.{flagKey} — for example, checkout.charge-delivery-fee.

2. Copy your SDK key

Go to Settings → Environments and copy the SDK key for the environment you’re targeting. SDK keys are environment-scoped — use separate keys for development, staging, and production.
sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   ← production
sk_dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   ← development

3. Install and initialise the SDK

npm install @omniretail/omniflags-react
Wrap your application root with OmniFlagsProvider. This triggers the initial snapshot fetch and makes the flag client available to all descendant components via context.
// main.tsx
import { createRoot } from 'react-dom/client';
import { OmniFlagsProvider } from '@omniretail/omniflags-react';
import App from './App';

createRoot(document.getElementById('root')!).render(
  <OmniFlagsProvider sdkKey="sk_live_...">
    <App />
  </OmniFlagsProvider>
);

4. Evaluate your flag

import { useFlag } from '@omniretail/omniflags-react';

function CheckoutButton({ customerId }: { customerId: string }) {
  const chargeDeliveryFee = useFlag('checkout.charge-delivery-fee', { customerId });

  return (
    <Button>
      {chargeDeliveryFee ? 'Proceed to payment' : 'Continue — free delivery'}
    </Button>
  );
}

Next steps