SongGuess
    Preparing search index...

    Feature flags binding for evaluating feature flags from a Cloudflare Workers script.

    // Get a boolean flag value with a default
    const enabled = await env.FLAGS.getBooleanValue('my-feature', false);

    // Get a flag value with evaluation context for targeting
    const variant = await env.FLAGS.getStringValue('experiment', 'control', {
    userId: 'user-123',
    country: 'US',
    });

    // Get full evaluation details including variant and reason
    const details = await env.FLAGS.getBooleanDetails('my-feature', false);
    console.log(details.variant, details.reason);
    Index

    Constructors

    Methods

    • Get a flag value without type checking.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • OptionaldefaultValue: unknown

        Optional default value returned when evaluation fails.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<unknown>

    • Get a boolean flag value with full evaluation details.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: boolean

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<FlagshipEvaluationDetails<boolean>>

    • Get a boolean flag value.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: boolean

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<boolean>

    • Get a number flag value with full evaluation details.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: number

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<FlagshipEvaluationDetails<number>>

    • Get a number flag value.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: number

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<number>

    • Get an object flag value with full evaluation details.

      Type Parameters

      • T extends object

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: T

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<FlagshipEvaluationDetails<T>>

    • Get an object flag value.

      Type Parameters

      • T extends object

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: T

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<T>

    • Get a string flag value with full evaluation details.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: string

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<FlagshipEvaluationDetails<string>>

    • Get a string flag value.

      Parameters

      • flagKey: string

        The key of the flag to evaluate.

      • defaultValue: string

        Default value returned when evaluation fails or the flag type does not match.

      • Optionalcontext: FlagshipEvaluationContext

        Optional evaluation context for targeting rules.

      Returns Promise<string>