Skip to content

Feature flags in React: SDKs, hooks and how to avoid flicker

How to use feature flags in React: the React SDKs and hooks of 12 tools compared, a tested OpenFeature React example, bootstrapping and SSR to avoid a flash of the wrong content, and what client-side flags expose.

5 min read

Short answer: Most feature flag tools ship a React SDK: a provider component at the top of your app and a hook such as useFlag to read a flag in any component. The two problems to plan for are the first render, where flags may not be loaded yet, and the fact that anything sent to the browser can be read by users.

Which React SDKs and hooks do the tools offer?

From each package's README or docs, with versions from npm, checked on 15 November 2026.

Tool Package Provider Boolean hook Avoid a flash on first render
OpenFeature (any provider) @openfeature/react-sdk 1.4.1 OpenFeatureProvider useBooleanFlagValue (or useFlag, which returns details) Suspense (experimental); otherwise depends on the provider
LaunchDarkly @launchdarkly/react-sdk 4.2.3 (renamed from launchdarkly-react-client-sdk) createLDReactProvider useBoolVariation bootstrap option; LDIsomorphicProvider for React Server Components
Unleash @unleash/proxy-client-react 6.0.1 FlagProvider useFlag useFlagsStatus to wait; bootstrap config; separate @unleash/nextjs
GrowthBook @growthbook/growthbook-react 2.0.0 GrowthBookProvider useFeatureIsOn SSR examples for Next.js, or pass the features JSON; <FeaturesReady> for a loading state
Flagsmith @flagsmith/flagsmith 12.5.0 (React hooks under /react) FlagsmithProvider useFlags (flags.x.enabled) serverState from the isomorphic client
ConfigCat configcat-react 5.1.0 ConfigCatProvider useFeatureFlag (returns value and loading) Not documented (use loading)
PostHog @posthog/react 1.11.3 PostHogProvider useFeatureFlagEnabled Bootstrapping with precomputed flags
Statsig @statsig/react-bindings 3.33.8 StatsigProvider useGateValue useClientBootstrapInit with server-provided values
DevCycle @devcycle/react-client-sdk 1.45.13 DevCycleProvider, withDevCycleProvider useVariableValue bootstrapConfig; separate @devcycle/nextjs-sdk
Split / Harness FME @splitsoftware/splitio-react 2.6.3 SplitFactoryProvider useTreatment (returns a treatment such as "on") initialRolloutPlan from the Node SDK
Optimizely @optimizely/react-sdk 4.3.0 OptimizelyProvider useDecide (decision.enabled) Pre-fetched datafile for SSR
Reflag @reflag/react-sdk 1.7.4 ReflagProvider useFlag (isEnabled) ReflagBootstrappedProvider with server data

Sources: OpenFeature React SDK, ConfigCat config visibility, Harness FME evaluation modes, Unleash browser client, LaunchDarkly React, Unleash React, GrowthBook React, Flagsmith JavaScript and Next.js and SSR, ConfigCat React, PostHog React, Statsig React, DevCycle React, Harness FME React, Optimizely React, Reflag React.

Other tools with React support listed on their profiles include Datadog Feature Flags, FeatBit, Flipt, GO Feature Flag and Tggl, several of them through OpenFeature providers.

How do I read a flag in a React component?

With OpenFeature's React SDK, the code is the same whichever tool you use; only the provider changes. We tested this code with @openfeature/react-sdk 1.4.1, @openfeature/web-sdk 1.10 and React 19.3, rendered in the browser; the in-memory provider stands in for a real one:

import { OpenFeature, InMemoryProvider } from '@openfeature/web-sdk'
import { OpenFeatureProvider, useBooleanFlagValue } from '@openfeature/react-sdk'

function Checkout() {
  const newCheckout = useBooleanFlagValue('new-checkout', false)
  return <p>{newCheckout ? 'New checkout' : 'Old checkout'}</p>
}

OpenFeature.setContext({ targetingKey: 'user-42', plan: 'pro' })
OpenFeature.setProvider(
  new InMemoryProvider({
    'new-checkout': {
      variants: { on: true, off: false },
      defaultVariant: 'off',
      disabled: false,
      contextEvaluator: (ctx) => (ctx.plan === 'pro' ? 'on' : 'off'),
    },
  }),
)

export function App() {
  return (
    <OpenFeatureProvider>
      <Checkout />
    </OpenFeatureProvider>
  )
}

When the user changes, for example after login, call OpenFeature.setContext with the new user; components re-render with the new values by default (opt out per hook with updateOnContextChanged: false). In our test, switching the context from a "pro" to a "free" user re-rendered the component from "New checkout" to "Old checkout".

Two caveats:

  • The in-memory provider is ready at once. A real provider returns the default (false) until it has loaded, so the first render needs a plan (next section).
  • @openfeature/web-sdk is for the browser. It holds one global context, so calling setContext on a server would share one user's context across requests; on the server, evaluate per request with @openfeature/server-sdk.

How do I avoid a flash of the wrong content?

On the first render, a client SDK usually hasn't fetched flags yet, so hooks return the default value and then switch. Users see the old version flash before the new one. The options, in rough order of effort:

  • Show a loading state until flags are ready. Unleash's useFlagsStatus, ConfigCat's loading, Split's isReady, Optimizely's isLoading, LaunchDarkly's useInitializationStatus, Flagsmith's useFlagsmithLoading, DevCycle's useIsDevCycleInitialized and GrowthBook's <FeaturesReady> all tell you when values are real. OpenFeature's React SDK can suspend until the provider is ready (useSuspenseFlag or { suspend: true }), which it marks as experimental.
  • Bootstrap from your server. Pass data to the client SDK so the first render already has the right values. Some SDKs take evaluated values (Flagsmith's server state, PostHog, Statsig, Reflag, LaunchDarkly, Unleash); others take the rule definitions (GrowthBook's features JSON, Split's rollout plan, Optimizely's datafile), which then reach the browser. DevCycle documents a bootstrapConfig option too.
  • Render on the server. With Next.js or another SSR framework, evaluate on the server and send finished HTML; several vendors have dedicated Next.js SDKs.
  • Pick safe defaults. If the default value is what most users see anyway, a late switch affects fewer people.

What do client-side flags expose?

Everything the browser receives is visible to users:

  • Flag keys and values can reveal unreleased features: name flags neutrally if that matters.
  • Rules, when the SDK evaluates in the browser. GrowthBook, ConfigCat, Split's standard SDK and Optimizely download rules or a datafile and evaluate in the browser, where users can read targeting rules; GrowthBook offers remote evaluation to hide them. Unleash's frontend SDKs and the client SDKs of LaunchDarkly, Statsig, PostHog and Reflag receive results evaluated on the server instead.
  • The flag is not a permission check. Hiding a button with a flag doesn't protect the API behind it; check access on the server (see entitlements vs feature flags).

How do I test React components that use flags?

Wrap the component in a provider that returns fixed values. With OpenFeature, use the in-memory provider shown above, or the SDK's testing helpers; most vendor SDKs document overrides or a test mode. Test both variants of each flag, and remove the flag and its tests together when it's done (see stale feature flags). For server code and other SDKs, see testing code that uses feature flags.

Which should I use?

  • Want to switch tools later, or use more than one? Use @openfeature/react-sdk with your vendor's web provider.
  • Already chose a tool? Its own React SDK usually exposes more features, such as experiments and events.
  • Using Next.js? See feature flags in Next.js: evaluating on the server avoids most flicker problems.

For native apps, see feature flags in iOS and Android apps. For the server side, see local vs remote evaluation; to pick a tool, see the best feature flag tools or the directory.