@launchdarkly/react-sdk - v4.2.3
    Preparing search index...

    Interface LDServerSession

    A per-request evaluation scope that binds an LDServerBaseClient to a specific LDContext.

    This is idiomatic for React Server Components, where the context comes from the incoming request (headers, cookies, auth tokens) and does not change during the render.

    Create a session with createLDServerSession.

    interface LDServerSession {
        allFlagsState(options?: LDFlagsStateOptions): Promise<LDFlagsState>;
        boolVariation(key: string, defaultValue: boolean): Promise<boolean>;
        boolVariationDetail(
            key: string,
            defaultValue: boolean,
        ): Promise<LDEvaluationDetailTyped<boolean>>;
        getContext(): LDContextStrict;
        initialized(): boolean;
        jsonVariation(key: string, defaultValue: unknown): Promise<unknown>;
        jsonVariationDetail(
            key: string,
            defaultValue: unknown,
        ): Promise<LDEvaluationDetailTyped<unknown>>;
        numberVariation(key: string, defaultValue: number): Promise<number>;
        numberVariationDetail(
            key: string,
            defaultValue: number,
        ): Promise<LDEvaluationDetailTyped<number>>;
        stringVariation(key: string, defaultValue: string): Promise<string>;
        stringVariationDetail(
            key: string,
            defaultValue: string,
        ): Promise<LDEvaluationDetailTyped<string>>;
    }
    Index
    • Builds an object encapsulating the state of all feature flags for this session's context.

      The most common use case is bootstrapping client-side flags from a back-end service. Call toJSON() on the returned object to get the data structure used by the client SDK.

      Parameters

      • Optionaloptions: LDFlagsStateOptions

      Returns Promise<LDFlagsState>

    • Determines the boolean variation of a feature flag for this session's context.

      Parameters

      • key: string
      • defaultValue: boolean

      Returns Promise<boolean>

    • Determines the boolean variation of a feature flag, along with evaluation details.

      Parameters

      • key: string
      • defaultValue: boolean

      Returns Promise<LDEvaluationDetailTyped<boolean>>

    • Determines the JSON variation of a feature flag for this session's context.

      This version is preferred in TypeScript because it returns unknown instead of any, requiring an explicit cast before use.

      Parameters

      • key: string
      • defaultValue: unknown

      Returns Promise<unknown>

    • Determines the JSON variation of a feature flag, along with evaluation details.

      Parameters

      • key: string
      • defaultValue: unknown

      Returns Promise<LDEvaluationDetailTyped<unknown>>

    • Determines the numeric variation of a feature flag for this session's context.

      Parameters

      • key: string
      • defaultValue: number

      Returns Promise<number>

    • Determines the numeric variation of a feature flag, along with evaluation details.

      Parameters

      • key: string
      • defaultValue: number

      Returns Promise<LDEvaluationDetailTyped<number>>

    • Determines the string variation of a feature flag for this session's context.

      Parameters

      • key: string
      • defaultValue: string

      Returns Promise<string>

    • Determines the string variation of a feature flag, along with evaluation details.

      Parameters

      • key: string
      • defaultValue: string

      Returns Promise<LDEvaluationDetailTyped<string>>