Evaluate feature flags

Gate features with remotely evaluated flags and variants.

Feature flags are evaluated for the current person. Use them for staged rollouts, experiments, and remote configuration.

Evaluate flags

Keep the requested key array stable so the hook does not re-run on every render:

const FLAG_KEYS = ["new-onboarding", "pricing-test"];

export function HomeScreen() {
  const { getVariant, isEnabled, isLoading } = voidhash.useFeatureFlags(FLAG_KEYS);

  if (isLoading) return null;

  const pricing = getVariant("pricing-test");

  return (
    <Home
      newOnboarding={isEnabled("new-onboarding")}
      pricingVariant={pricing?.enabled ? pricing.variantKey : null}
    />
  );
}

The hook returns:

ValuePurpose
data.flagsAll evaluated results.
isEnabled(key)Whether a flag is enabled. Unknown and loading flags return false.
getVariant(key)The enabled state, variant key, and optional payload, or null.
isLoading, error, refetchRequest state and retry control.

Validate a variant payload before using it; payloads are untyped JSON.

Identity behavior

Flag results are scoped to the current person. The SDK clears them after identify() or a sign-out/reset so one customer never sees another customer's assignment.

Choose a safe default while a flag is loading or unavailable. For paid access, use entitlement grants rather than a feature flag.