---
title: "OpenFeature"
description: "Use any OpenFeature provider for MainSDK feature flags - main.yaml, flags.enabled and flags.value, testing and swapping flag tools."
section: "integrations"
canonical: "https://mainsdk.dev/docs/integrations/openfeature"
updated: "2026-10-28"
---

# OpenFeature

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

Canonical: https://mainsdk.dev/docs/integrations/openfeature · Updated: 2026-10-28

OpenFeature is the open standard for feature flag evaluation, and the `openfeature` driver lets [`flags`](https://mainsdk.dev/docs/interfaces/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.

> **Note:** `flags` has no spec yet. The calls and options on this page are provisional and may change when the spec lands.

## Interfaces it serves

### Feature flags (`flags`)

- Status: Preview · ships as a beta API
- Driver: `openfeature` (Any OpenFeature provider). planned; definitions then stay in that tool
- Docs: https://mainsdk.dev/docs/interfaces/flags.md

```yaml
flags:
  driver: openfeature
```

Swap to another provider: `config`, `posthog`, `vercel-flags`.

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

```yaml title="main.yaml"
flags:
  driver: openfeature
  # [TBD] how the provider is named and its key passed, as secret:FLAGS_SDK_KEY (suggested name)
```

## Use it

```ts title="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](https://mainsdk.dev/docs/interfaces/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](https://mainsdk.dev/docs/interfaces/access). Keep personal data out of flag names and values.

## Swap to or from it

```yaml title="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

- [Feature flags](https://mainsdk.dev/docs/interfaces/flags) and [Runtime settings](https://mainsdk.dev/docs/interfaces/config)
- [PostHog](https://mainsdk.dev/docs/integrations/posthog) and [Vercel](https://mainsdk.dev/docs/integrations/vercel)
