← Blog

OpenFeature explained, and where dif's model differs

OpenFeature is a CNCF specification that standardizes how application code calls a feature flag. The same getBooleanValue() call works whether the flag lives in LaunchDarkly, Split, Unleash, or a file in your repo. It fixes vendor lock-in at the call site, but it does not decide where a flag is defined or who manages it; that part is still up to whatever sits behind the call. dif ships an OpenFeature provider, @dif.sh/openfeature, that plugs dif’s git-native flags into that exact call site.

flagd is the closest the OpenFeature ecosystem gets to a file-based answer to that open question, and it still runs as a daemon your app queries at evaluation time. dif’s answer is different: flags as Markdown files in the repo, with no daemon in between.

Key Takeaways

  • OpenFeature is a CNCF incubating specification (since December 19, 2023) for a vendor-agnostic flag evaluation API. It standardizes the call, not where the flag lives.
  • The spec’s own scope statement: it covers “feature flag evaluation in application code,” and leaves flag definition and management to each vendor’s provider.
  • dif’s official provider, @dif.sh/openfeature, resolves OpenFeature.getClient() calls against the same Markdown files and assign() function the dif() call uses, so both return the same variant for the same user.
  • Using dif through OpenFeature costs you dif’s typed branches, dif validate’s orphan check (W001), browser exposure dedupe, and the React/Svelte adapters. dif’s own README calls the provider “a bridge, not the primary API.”
  • getBooleanValue on a dif experiment with three or more variants collapses every non-control variant to true; use getStringValue when you need to tell them apart.

What the OpenFeature specification actually standardizes

OpenFeature is a Cloud Native Computing Foundation project. It entered the CNCF Sandbox in 2022 and was voted into Incubating status on December 19, 2023, backed by Dynatrace alongside GitLab, LaunchDarkly, and Split. The spec defines three things: an evaluation API your code calls, a Provider interface that vendors implement, and Hooks that run at four points in the evaluation lifecycle (before, after, error, finally) for telemetry and logging.

The scope is narrow by design. The spec’s own introduction states that it “focuses primarily on feature flag evaluation in application code, leaving the definition and management of feature flags up to the feature flag management system.” That line is the whole story: OpenFeature standardizes how you ask for a flag’s value. It says nothing about where that value is stored, who edits it, or how a change gets reviewed. The provider catalog lists more than 30 vendors, each implementing that same Provider interface over a completely different backend: a SaaS dashboard, a database, or flagd’s JSON file.

The evaluation API, in code

A client asks for a flag by key and gets back either a bare value or a details object with a reason code:

import { OpenFeature } from "@openfeature/server-sdk";

const client = OpenFeature.getClient();
const newCheckout = await client.getBooleanValue("new-checkout", false, {
  targetingKey: user.id,
});

Every call takes a default value, returned on any evaluation error, and an Evaluation Context: a targetingKey plus attributes (device type, plan, region) the provider uses for targeting. Four flag types exist: boolean, string, number, and object. Swap OpenFeature.setProvider() to a different vendor and every getBooleanValue call site stays untouched.

What OpenFeature leaves open: flagd and the provider gap

The spec’s narrow scope means someone still has to answer “where do flags live and how do they change?” flagd is a standalone daemon that reads flag definitions from a JSON file and serves evaluations over gRPC, deployed as a sidecar, in-process, or a central service. It is still a process your app queries at evaluation time. The Kubernetes-native path, the OpenFeature Operator, injects it as a sidecar reading a custom resource, not a file your pull request reviews directly.

A vendor’s hosted Provider answers the same question differently: the flag lives in that vendor’s dashboard, and your app’s OpenFeature client calls out to it (directly or through a local cache) to get a current value. Either way, the thing that changes a flag’s behavior is not in your repo’s diff.

dif’s provider: the same files, through OpenFeature

dif’s answer to “where do flags live” is a Markdown file in dif/experiments/active/, reviewed in a pull request like any other change (feature flags in git covers that workflow in full). @dif.sh/openfeature is dif’s official server provider, so a codebase already calling OpenFeature.getClient() can point those calls at dif’s files without rewriting the call sites:

npm i @dif.sh/sdk @dif.sh/openfeature @openfeature/server-sdk
import "./dif/generated/client"; // registers every active experiment
import { OpenFeature } from "@openfeature/server-sdk";
import { DifOpenFeatureProvider } from "@dif.sh/openfeature";

OpenFeature.setProvider(new DifOpenFeatureProvider());
const client = OpenFeature.getClient();

const newCheckout = await client.getBooleanValue("new-checkout", false, {
  targetingKey: user.id,
  device_type: "mobile",
});

The provider has no initialize() step, because dif build already compiled every active experiment into dif/generated/client.ts before this file runs; importing it is what fills the registry the provider reads. targetingKey becomes the user id dif hashes with the experiment’s salt to pick a bucket (0 to 9,999); any other scalar on the context becomes an attribute the experiment’s audience: block is evaluated against. reason on the details object tells you why: SPLIT for a real bucketed decision, STATIC for a QA override, DEFAULT when there’s no targeting key or the audience didn’t match, ERROR for a flag id that was never registered.

Where dif’s model differs

OpenFeature’s Provider interface exists because, for most of its ecosystem, the backend is a separate service worth abstracting away. dif doesn’t try to be provider-agnostic to its own backend, because there’s intentionally one backend: the repo. dif build is the only build step, the generated client is the only registry, and the OpenFeature provider adds zero network calls on top of what dif() already does, not a gRPC round trip to a sidecar.

Going through OpenFeature.getClient() instead of calling dif() directly gives up four things, and dif’s own documentation says so plainly: the provider is “a bridge, not the primary API.”

  • Typed branches. dif("new-checkout", { off: () => …, on: () => … }) takes its branch keys from the experiment’s declared variants:, so a renamed variant fails the type check. client.getBooleanValue("new-checkout", false) takes a plain string TypeScript can’t verify against anything.
  • Orphan detection. dif validate warns with W001 when a dif("...") call site in your source references an experiment that isn’t active. It only pattern-matches dif("…") calls, so an OpenFeature get*Value call referencing a dead flag goes unnoticed.
  • Exposure dedupe. The browser dif() call dedupes exposure events per user per experiment. The provider’s onExposure callback fires on every SPLIT evaluation, undeduplicated, so one request that evaluates a flag twice logs it twice if you forward it to analytics as-is.
  • Framework adapters. @dif.sh/react and @dif.sh/svelte assign a variant on the server and hand that same decision to the client, so a user never sees the variant flip after hydration. The OpenFeature path has no equivalent handoff.

Mapping dif’s experiment format onto OpenFeature’s four flag types turns up a second difference: dif only resolves to two of them. getStringValue returns the variant id. getBooleanValue returns false for the first declared variant (the control) and true for any other, so a flag with off/on variants maps cleanly, but a three-way test (control / variant_a / variant_b) collapses both non-control variants to true. getNumberValue and getObjectValue always return your default with a TYPE_MISMATCH error, because a dif experiment resolves to a variant id, not an arbitrary JSON config value the way some vendors use flags for.

When the OpenFeature provider is the right call

Reach for @dif.sh/openfeature when your services already call OpenFeature.getClient() everywhere and you’re moving flags into the .md format without touching those call sites, when dif is running as one of several providers during a migration off another vendor, or when you depend on OpenFeature hooks for evaluation telemetry. Both paths read the same registry: a dif() call and a getStringValue call for the same experiment and user return the same variant, so they can run side by side during a cutover.

Reach for dif() from the SDK directly everywhere else. It is still dif’s primary interface, and it checks more at build time, with dif validate and dif build catching the mistakes the OpenFeature path can’t see.

FAQ

Is dif an OpenFeature provider? Yes. @dif.sh/openfeature is dif’s official server provider for the OpenFeature JavaScript SDK. It resolves OpenFeature.getClient() evaluations against the same experiment files and assign() function the dif() call uses.

What is flagd? flagd is a standalone, OpenFeature-compliant daemon that evaluates flags defined in a JSON file. It runs as a sidecar, in-process, or a central service your app queries over gRPC at evaluation time.

Does OpenFeature replace tools like LaunchDarkly or Split? No. OpenFeature standardizes the call your code makes; LaunchDarkly, Split, and dif are all providers you plug in behind that call. Swapping providers means changing one setProvider() line, not every get*Value call site.

Can I evaluate number or object flags through dif’s OpenFeature provider? No. dif experiments resolve to a variant id (getStringValue) or a boolean (getBooleanValue). getNumberValue and getObjectValue return your default with a TYPE_MISMATCH error, because dif flags aren’t a vehicle for arbitrary JSON config.

Do I need OpenFeature if I’m already using dif? No. dif() from @dif.sh/sdk is the primary way to call a dif flag, and it catches more at build time than the OpenFeature path can. Add the provider only if your codebase already standardized on OpenFeature.getClient() or you’re migrating off another vendor and want dif running alongside it.

Picking a path

OpenFeature standardizes one thing well: the shape of the call your application code makes to evaluate a flag. It was voted into CNCF Incubating status in December 2023 on that narrow premise, and it deliberately leaves where a flag is defined and managed to whatever provider sits behind the call. dif’s answer to that open question is a Markdown file in your repo, compiled by dif build, with no daemon and no network call. @dif.sh/openfeature lets a team that already calls OpenFeature.getClient() point those calls at dif’s files directly, at the cost of the type safety, orphan detection, and framework handoff that calling dif() gives you for free. Install it with npm i @dif.sh/sdk @dif.sh/openfeature @openfeature/server-sdk, or start from the docs if you’re adopting dif for the first time.