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

Remarks

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.

Hierarchy

  • LDServerSession

Methods

  • 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

    • Optional options: LDFlagsStateOptions
      Optional

    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>>

Generated using TypeDoc