API Reference
    Preparing search index...

    Evaluates feature flags against a caller-supplied Store.

    Infers the Store's value type. Variant stores require full Variant fallbacks and return Variants without schemas; JSON stores retain primitive inference and optional Standard Schema validation.

    const flags = new FeatureFlags({ store: myStore });
    const enabled = await flags.evaluate({ name: 'checkout_v2', default: false });

    Type Parameters

    Index
    • Evaluates one flag and returns its value or the required fallback.

      Handles StoreUnavailableError with the fallback. With a schema, validates the fallback before contacting the Store and replaces the primitive type check with schema validation. Returns the validated output on both the found path and the fallback path, and rejects schema outputs that are undefined. Variant stores require a full Variant fallback, return it unchanged on a fallback path, and do not accept schemas.

      Type Parameters

      • Schema extends StandardSchemaV1<unknown, unknown>

      Parameters

      Returns Promise<InferOutput<Schema>>

      const enabled = await flags.evaluate({
      name: 'checkout_v2', context: { tier: 'premium' }, default: false,
      });
      const settings = await flags.evaluate({
      name: 'settings', default: { theme: 'light' }, schema: settingsSchema,
      });
    • Evaluates one flag and returns its value or the required fallback.

      Handles StoreUnavailableError with the fallback. With a schema, validates the fallback before contacting the Store and replaces the primitive type check with schema validation. Returns the validated output on both the found path and the fallback path, and rejects schema outputs that are undefined. Variant stores require a full Variant fallback, return it unchanged on a fallback path, and do not accept schemas.

      Type Parameters

      Parameters

      Returns Promise<Value extends Variant ? Variant : EvaluateResult<Fallback>>

      const enabled = await flags.evaluate({
      name: 'checkout_v2', context: { tier: 'premium' }, default: false,
      });
      const settings = await flags.evaluate({
      name: 'settings', default: { theme: 'light' }, schema: settingsSchema,
      });