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.
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:
export FLAGON_SDK_KEY="flagon_sdk_..."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 defaultThe 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:
const showCheckout = await client.getBooleanValue("new-checkout", false, {
targetingKey: "user-123",
});
console.log(showCheckout); // trueThat's the whole loop: change configuration in the console, and your app picks it up on the next evaluation, with no deploy.
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
- Targeting and segments: turn the flag on for just your team, a percentage of users, or a named audience.
- Environments: promote the same flag from Development to Production.
- Evaluate with OpenFeature: patterns for other languages and for the browser.