Flagon

Quickstart

By the end of this page you will have a flag you can flip from the console and read from your application. It takes about five minutes.

You will need a Flagon workspace (organization). If you do not have one yet, an invite from your team gets you in; then open the console.

1. Create a flag

In the console, open Flags and choose New flag. For this walkthrough:

  • Key: new-checkout. This is the stable identifier your code evaluates.
  • Type: Boolean.
  • Description: optional, but future you will appreciate it.

A boolean flag is created with two variants, on (true) and off (false). By default it is off in every environment, so shipping the flag changes nothing until you decide to turn it on.

Flag keys are forever-ish

The key is what your code references, so pick a clear, lowercase, hyphenated name. You can rename the display name freely, but changing the key means changing your code.

2. Create an SDK key

Evaluation is authenticated with an SDK key, and each key belongs to one environment. Open Flags → SDK Keys, pick Development for now, and create a key.

The key is shown once. Copy it and set it as an environment variable in your app:

Shell
export FLAGON_SDK_KEY="flagon_sdk_..."
Treat it like a secret

An SDK key can read every flag's configuration in its environment. Keep it out of source control and out of your git history. If one leaks, revoke it from the SDK Keys page and mint a new one.

3. Evaluate it from your app

Install the OpenFeature SDK and the OFREP provider for your language, then point the provider at Flagon with your key and evaluate. Pick your language once (top right) and it sticks across the docs.

// npm install @openfeature/server-sdk @openfeature/ofrep-provider
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",
});
console.log(showCheckout); // false: the flag is off by default

The default value (false) is what your code uses if the flag can't be reached or doesn't exist. Evaluation always returns a value, so a network blip never throws in your request path.

4. Flip it and watch it change

Back in the console, open the flag, switch Development on, and set the default variant to on. Run your snippet again:

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

console.log(showCheckout); // true

That's the whole loop: change configuration in the console, and your app picks it up on the next evaluation, with no deploy.

Propagation

A configuration change is reflected within a few seconds. Flagon serves flag config from a short-lived cache on the evaluation path, so a change is live almost immediately, not instantly to the millisecond.

Next steps