Skip to content

Feature flags (SDK)

For creating flags, targeting and rollout mechanics, read the feature flags guide. This page is the SDK surface.

// Boolean check — false until flags load, false for unknown keys
if (kilden.isFeatureEnabled('new-checkout')) {
renderNewCheckout();
}
// Full value — boolean flag or the variant key of a multivariate flag
const variant = kilden.getFeatureFlag('pricing-test'); // true | false | "variant-b" | undefined
isFeatureEnabled(key: string): boolean;
getFeatureFlag(key: string): boolean | string | undefined;

Flags load from POST {apiHost}/decide at init and are cached in memory for the session. Neither getter ever blocks:

  • isFeatureEnabled returns false until flags load.
  • getFeatureFlag returns undefined until flags load — so you can distinguish “off” (false) from “not loaded yet” (undefined). Every flag in the project comes back in each response (inactive ones as false), so a missing key after load means the flag doesn’t exist.
kilden.onFeatureFlags((flags) => {
// flags: Record<string, boolean | string>
setupUi(flags['new-checkout'] === true);
});

The callback fires when flags first load, on every reload, and immediately if you subscribe after they already loaded. Use it to avoid rendering before flags are known.

Flags reload automatically after identify() and reset() — the evaluation depends on the distinct id, so the SDK converges to the new id’s values right away. Because bucketing hashes the distinct id, a user near a rollout boundary can legitimately change sides when they go from anonymous to identified; see the guide for why.

There is no bootstrap option: the first evaluation of a page load is always an async /decide call. Gate flag-dependent UI on onFeatureFlags rather than assuming values at startup.

The first access to a flag per session — through either getter — emits a $feature_flag_called event with $flag_key and $flag_value, which powers exposure charts in the panel. The dedupe is keyed by $session_id and survives page reloads; it resets when the session rotates. Unknown flag keys emit nothing.

While opted out, /decide is not called; cached values keep answering.