Evaluate feature flags
Turn features on and pick variants per person, without an app release.
Voidhash evaluates feature flags for the current person, so one flag can be on for some people and off for others. You create flags and set their rollout in Studio; the SDK reads the result.
Feature flags are in early access. Ask us on Discord, or email support@voidhash.com on a paid plan, to turn them on for your team.
A build that uses a test key gets each flag's test configuration, which is the same as production's until you change it in Studio. See Environments.
Evaluate flags
Pass the keys you need. The hook compares keys by value, in any order, so an inline array doesn't cause extra requests:
import { voidhash } from "../src/lib/voidhash";
export function HomeScreen() {
const { isEnabled, getVariant, isLoading } = voidhash.useFeatureFlags([
"new-onboarding",
"pricing-test",
]);
if (isLoading) return null;
const pricing = getVariant("pricing-test");
return (
<Home
newOnboarding={isEnabled("new-onboarding")}
pricingVariant={pricing?.enabled ? pricing.variantKey : null}
/>
);
}Omit the keys to evaluate every flag.
| Value | Meaning |
|---|---|
isEnabled(key) | Whether the flag is on. false while loading and for unknown or disabled flags. |
getVariant(key) | { enabled, variantKey, payload }, or null while loading or for an unknown flag. |
data.flags | Every evaluated flag: key, enabled, variantKey, payload. |
isLoading, error, refetch | Request state, and a way to evaluate again. |
variantKey is null for a flag without variants. payload is untyped JSON, or null; validate it
before use.
Outside React, client.getFeatureFlags(keys?) resolves to { flags, isStale }.
Defaults and caching
The SDK has no local defaults: a disabled, unknown or still-loading flag reads as off. Write your code so that off is the safe behavior.
Results are cached on the device and served from cache for 5 minutes. After that, a read answers from cache while a refresh runs, so flags keep working offline. The SDK also evaluates again at launch and on foreground. A change in Studio reaches the app at the next refresh.
Identity
Flags are evaluated per person. After identify(), signOut() or reset(), mounted hooks evaluate
again for the new person. Rollouts bucket by person, so the same person gets the same answer on every
device once identified.
Don't gate paid access on a flag. Use perks for that.
Next steps
Something wrong or missing on this page? Tell us by email or on Discord.