OpenFeature
Use any OpenFeature provider for MainSDK feature flags - main.yaml, flags.enabled and flags.value, testing and swapping flag tools.
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.
flagsPreviewDriver openfeature Any OpenFeature provider
planned; definitions then stay in that tool
flags:
driver: openfeatureSwap to another provider
Before you start
- Have an account with a flag tool that offers an OpenFeature provider for your runtime.
- Create the flags and targeting rules there, and store the tool's SDK key in your secrets manager.
Configure
flags:
driver: openfeature
# [to be decided] how the provider is named and its key passed, as secret:FLAGS_SDK_KEY (suggested name)Use it
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()orflags.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
flags:
driver: openfeature # was posthogYour 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
- Feature flags and Runtime settings
- PostHog and Vercel
Was this page helpful?