FF
FeatureFlare docs
Guides and API reference
API reference

FeatureFlareProvider

All props for controlled and uncontrolled usage.

Current section
Component and config reference
Use these pages when you need props, defaults, and provider behavior details.

FeatureFlareProvider

Top-level React provider that creates SDK + query context and manages current user state.

More on this: see FeatureFlareReactConfig for complete config field behavior.

export function FeatureFlareProvider(props: {
  config: FeatureFlareReactConfig;
  initialUser: FeatureFlareUserPayload;
  user?: FeatureFlareUserPayload;
  onUserChange?: (next: FeatureFlareUserPayload) => void;
  children: ReactNode;
})

Props

config: FeatureFlareReactConfig

Required SDK/provider configuration. Includes API base URL, keying information, cache/retry options, bootstrap state, metrics hook, and realtime options.

initialUser: FeatureFlareUserPayload

Required starting identity for evaluation. Used to initialize provider state and as the first user context for flag fetches. See FeatureFlareUserPayload for the full identity and attribute object shape.

user?: FeatureFlareUserPayload

Optional controlled user value. When set, the provider runs in controlled mode and does not own user state internally.

onUserChange?: (next: FeatureFlareUserPayload) => void

Optional callback for controlled mode updates. Required whenever user is provided; otherwise the provider throws an error.

children: ReactNode

Required React subtree that will receive FeatureFlare context and React Query context. ReactNode is the standard React type for renderable children, not a FeatureFlare-specific object.

Behavior Notes

  • Controlled mode rule: if user is provided, onUserChange must also be provided.
  • Uncontrolled mode: provider uses internal state initialized from initialUser.
  • Provider may return null temporarily when waiting for initial flag preload (based on config).

Related docs