Beignet API reference
    Preparing search index...

    Module @beignet/provider-flags-openfeature

    @beignet/provider-flags-openfeature

    Runtime: Beignet requires Node.js 22.12 or newer. Bun is optional.

    Caution

    Beignet is experimental alpha software. The 0.0.x package line is for early evaluation, and APIs may change between releases while the framework settles.

    OpenFeature-backed FlagsPort provider for Beignet applications.

    The provider installs ctx.ports.flags using @openfeature/server-sdk and keeps OpenFeature types out of Beignet core.

    bun add @beignet/provider-flags-openfeature @beignet/core @openfeature/server-sdk
    

    Install and configure your chosen OpenFeature provider package separately. This Beignet package does not require environment variables itself; your chosen OpenFeature provider may require its own SDK package and env vars.

    import { createNextServer, createNextServerLoader } from "@beignet/next";
    import { createOpenFeatureFlagsProvider } from "@beignet/provider-flags-openfeature";
    import { initialPorts } from "@/infra/port-wiring";
    import { openFeatureProvider } from "@/infra/flags/openfeature";

    export const getServer = createNextServerLoader(() =>
    createNextServer({
    ports: initialPorts,
    providers: [
    createOpenFeatureFlagsProvider({
    provider: openFeatureProvider,
    domain: "app",
    }),
    ],
    context: appContextBlueprint,
    }),
    );

    The provider contributes:

    • ctx.ports.flags, the standard Beignet FlagsPort
    • ctx.ports.openFeature, an escape hatch with the raw OpenFeature client/API

    Passing client means the app already owns OpenFeature registration; setup uses that client and does not install provider on the process-global OpenFeature API. By default shutdown leaves global bindings alone. Set restoreOnStop: true only when this Beignet provider should restore the effective provider that was bound to its domain before setup. Restoration is scoped to that binding and is skipped if another owner replaced it after setup; Beignet never clears unrelated OpenFeature providers.

    beignet doctor --strict checks that installed OpenFeature flag providers are registered in server/providers.ts.

    Use createOpenFeatureFlags(...) when your app already owns an OpenFeature client:

    import { createOpenFeatureFlags } from "@beignet/provider-flags-openfeature";

    const flags = createOpenFeatureFlags({ client });

    OpenFeature evaluation errors return the Beignet flag default with reason: "error" in details(...). Programmer errors, such as malformed flag definitions, remain application errors.

    Provider-neutral context.attributes are forwarded to OpenFeature unchanged. Defined Beignet context fields such as tenant.id, subject.id, requestId, and traceId authoritatively replace attributes with their reserved OpenFeature keys; when those fields are absent, an app-supplied attribute with the same key is preserved.

    When @beignet/devtools is installed before this provider, flag evaluations, provider errors, explicit exposures, and tracking events appear under the Feature flags watcher. Private attributes are redacted from instrumentation details.

    Use OpenFeature's in-memory provider, or an app-owned fake FlagsPort, in tests. Feature flags are not authorization; use policies and gates for access control decisions that must be enforced.

    Configure the vendor OpenFeature provider before registering createOpenFeatureFlagsProvider(...). Keep default flag values explicit in Beignet flag definitions so provider outages degrade predictably.

    CreateOpenFeatureFlagsOptions
    CreateOpenFeatureFlagsProviderOptions
    OpenFeatureEscapeHatch
    OpenFeatureFlagsProviderPorts
    FlagEvaluationContext
    FlagEvaluationDetails
    FlagEvaluationOptions
    FlagExposureOptions
    FlagsPort
    FlagTrackOptions
    createOpenFeatureFlags
    createOpenFeatureFlagsProvider