Skip to main content
This guide walks you through every step needed to create a feature flag in Foff and read its value from a TypeScript application. By the end you will have a working integration that resolves flag values based on a real hierarchy.
1

Sign up for Foff

Go to foff.twospoon.ai and create an account using your email address. Foff sends a one-time passcode to your inbox — enter it to complete sign-in.
2

Create a workspace

After signing in, you are prompted to create a workspace. A workspace is the top-level container for all your feature flags and configuration. Give it a name that reflects your organization or product, then click Create workspace.Your new workspace appears in the top-left of the navigation bar. All the scopes and features you create are scoped to this workspace.
3

Create a scope

Select Scopes from the navigation bar, then click New scope.A scope defines the hierarchy shape that all its feature flags will follow. For this guide, use an organizational hierarchy:
LevelExample value
Companyzomato
Departmentonline-ordering
Teamriders
Useruser-123
Name the scope something descriptive — for example, employee-hierarchy — then save it. Foff displays the scope’s detail page once it is created.
4

Create a feature flag

Navigate to the Features section inside your scope and click New feature.For this guide, create a flag called dark-mode-ui with a boolean default value of true. This default applies to every user unless a more specific override exists.After saving, the feature appears in your scope’s feature list with its default value displayed.
5

Add a hierarchy override

Click Add override on the dark-mode-ui feature.Overrides let you return a different value for a specific path through your hierarchy. To disable dark mode for everyone in the Zomato → Online Ordering → Riders path, set:
  • Company: zomato
  • Department: online-ordering
  • Team: riders
  • Value: false
Save the override. It appears in the feature’s overrides list.
Hierarchy values in overrides are case-sensitive. Enter zomato, not Zomato — a mismatch means the override will never match and the default value will be returned instead.
6

Generate an API key

Click Developers in the navigation bar, then click Generate API key. Give the key a descriptive name (for example, local-dev) and click Create.
The API key is shown only once. Copy it and store it somewhere safe — for example, in a .env file or your secrets manager — before closing the dialog. You cannot retrieve it again.
You can manage all your keys from the Developers section: enable or disable a key, or restrict it to specific IP addresses.
7

Install the TypeScript SDK

Install the Foff TypeScript SDK. It requires Node.js 18 or later.
npm install @twospoon/foff-feature-config-typescript-sdk
8

Read your feature flag

Create a client using the API key you generated and the scope name you created earlier, then call getFeatureConfig with the feature name and the hierarchy path you want to resolve.
import { Client, Config } from "@twospoon/foff-feature-config-typescript-sdk";

const config = new Config({
  APIKey: process.env.FOFF_API_KEY!,
  BaseURL: "https://foff.twospoon.ai/live",
  Scope: "employee-hierarchy",
  PollingInterval: 30, // re-fetch configs every 30 seconds
});

const client = await Client.newClient(config);

// Resolves to `false` — matches the Zomato → Online Ordering → Riders override
const value = client.getFeatureConfig("dark-mode-ui", ["zomato", "online-ordering", "riders"]);
console.log(value); // false

client.close();
The SDK fetches all configs for your scope on startup and caches them in memory. getFeatureConfig resolves the hierarchy from most specific to least specific:
  1. zomato + online-ordering + riders — matches the override → returns false
  2. If no match, falls back to zomato + online-ordering, then zomato
  3. If no override matches at any level, returns the feature’s default value
For a user who is not in that hierarchy path, the default value of true is returned:
const value = client.getFeatureConfig("dark-mode-ui", ["acme-corp", "engineering", "backend"]);
console.log(value); // true (default)
For long-lived processes such as an Express server, create the client once at startup and call client.close() on process exit to stop background polling. See the SDK reference for lifecycle patterns and all configuration options.
You now have a working Foff integration. Any changes you make to flags or overrides in the dashboard will propagate to your running application within the polling interval — no redeploy required.