Flagon

Evaluate with OpenFeature

OpenFeature is a vendor-neutral standard for feature flags. Flagon implements its remote evaluation protocol (OFREP), so you use the standard OpenFeature SDK for your language plus the OFREP provider, pointed at Flagon by URL. There's no Flagon-specific client to adopt.

Pick your language once (top right, or the tabs on any sample) and every example on the page follows it.

1. Install

Add the OpenFeature SDK and the OFREP provider for your language.

npm install @openfeature/server-sdk @openfeature/ofrep-provider

2. Register the provider and evaluate

Configure the provider once, at startup: the baseUrl is the Flagon API host (the provider appends the OFREP path itself), authenticated with your SDK key as a bearer token. Then evaluate with a default value and an evaluation context.

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

await OpenFeature.setProviderAndWait(
new OFREPProvider({
  baseUrl: "https://api.flagon.io",
  headers: [["Authorization", "Bearer " + process.env.FLAGON_SDK_KEY]],
}),
);

const client = OpenFeature.getClient();

const showCheckout = await client.getBooleanValue("new-checkout", false, {
targetingKey: "user-123",
plan: "pro",
});

The default value (the second argument) is what your code uses if evaluation can't complete, so a network blip never throws in your request path. Flags of other types have matching methods: string, number, and object.

Set context once

Most SDKs let you set a global evaluation context (the signed-in user) once, so you don't pass it on every call. See your language's OpenFeature guide.

Get the reason and variant

When you need to know why a value came back (for logging or debugging), ask for the full evaluation details instead of just the value. Every result carries a reason (STATIC, TARGETING_MATCH, SPLIT, DISABLED) and, when applicable, the served variant.

const details = await client.getBooleanDetails("new-checkout", false, context);
console.log(details.value);   // true
console.log(details.reason);  // "TARGETING_MATCH"
console.log(details.variant); // "on"

Browser and mobile

For a web front end, use the OpenFeature Web SDK with the OFREP web provider (@openfeature/web-sdk + @openfeature/ofrep-web-provider).

Don't ship a Production key to the browser

Anything in a browser bundle is public. A Production SDK key in front-end code lets anyone read your full flag configuration. For untrusted clients, evaluate on your own server and send only the resulting values to the browser, or use a key scoped to a low-risk environment.

Other languages

OpenFeature also has SDKs for .NET, Ruby, Rust, and more. Where a first-party OFREP provider exists, the shape is the same: construct it with Flagon's base URL and an Authorization: Bearer header, register it, then evaluate. Where one doesn't exist yet (as with PHP above), call the protocol directly over REST. See the OpenFeature SDK list and the REST reference.

Next