MainSDK
Search⌘K
Integrations

OpenFeature

Use any OpenFeature provider for MainSDK feature flags - main.yaml, flags.enabled and flags.value, testing and swapping flag tools.

1 interface1 driverWritten guide
Updated 2026-10-28

OpenFeature is the open standard for feature flag evaluation, and the openfeature driver lets flags use any OpenFeature provider: LaunchDarkly, Flagsmith, Unleash, PostHog, Vercel Flags and others. Your flags and targeting rules stay in your tool. Pick it when you already have a flag tool, or want to keep the choice open.

Interfaces it serves

Pick OpenFeature in main.yaml for any of these. Your calls stay the same, and you can swap later.

Before you start

  1. Have an account with a flag tool that offers an OpenFeature provider for your runtime.
  2. Create the flags and targeting rules there, and store the tool's SDK key in your secrets manager.

Configure

main.yaml
flags:
  driver: openfeature
  # [to be decided] how the provider is named and its key passed, as secret:FLAGS_SDK_KEY (suggested name)

Use it

app/api/checkout/route.ts
import { auth, flags } from "mainsdk";

export async function GET(req: Request) {
  const session = await auth.require(req);
  const useNew = await flags.enabled("new-checkout", { for: session.user });
  return Response.json({ checkout: useNew ? "new" : "classic" });
}

Local development and testing

createTestApp() from @mainsdk/testing runs flags on an in-memory fake, so tests reach no flag provider, and chaos.on("flags", { outage: true }) simulates the provider being down. Helpers to set a flag on the fake arrive with the spec.

What MainSDK adds on top

  • Flags and targeting stay in your tool; MainSDK does not copy them out.
  • One call, flags.enabled() or flags.value(), whatever the tool.

See Feature flags.

Limits and notes

Planned driver, not in a spec yet (phase 1). A flag is not a permission: decide who may do what with Permissions. Keep personal data out of flag names and values.

Swap to or from it

main.yaml
flags:
  driver: openfeature   # was posthog

Your calls stay the same; recreate the flags in the new tool.

FAQ

Do I have to move off my flag tool? No. That is the point of the OpenFeature driver.

Next

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet