AccelerUpDocs
Feature flags/Client SDK

Feature flag SDK

Evaluating flags in the browser and on the server, including SSR bootstrap and the edge worker.

Client SDK

Ships in @accelerup-llc/web-monitor (v0.7.0+), so a page with the monitoring SDK evaluates flags without a second dependency.

js
import { flags } from '@accelerup-llc/web-monitor';

await flags.init({
  ingestUrl: 'https://monitoring.qrdev.org/ingest',
  key: 'YOUR_INGEST_KEY',
  subject: { id: user.id, plan: user.plan, country: user.country },
});

if (flags.isOn('new-checkout')) { … }
const variant = flags.variant('checkout-layout');   // 'a' | 'b'
const config  = flags.json('pricing-rules');        // typed value

Bulk resolve

/resolve evaluates every flag for a subject in one request.

Important

Use it. One request at page load beats one request per flag: the second pattern produces a waterfall, and the flags evaluated last arrive after the component that needed them has already rendered the default.

SSR bootstrap

Server-side rendering can resolve flags and pass them into the client as bootstrap data, so the first render already has the right values.

Without it, a flagged component renders the default, then flips — which is a visible flash and, for a layout flag, a layout shift that counts against CLS.

Server-side evaluation

Backend services call /resolve with the subject. Same evaluation, same answers, so a flag cannot disagree between the API and the page rendering its result.

The Cloudflare edge worker

Flags can be evaluated at the Cloudflare edge, which removes the round trip entirely for a page that only needs a handful.

Exposure tracking

When a subject is exposed to a variant, the SDK records it via /ingest/ab-uniques. Exposure — not page views — is the denominator every experiment result is computed against.

Warning

Record exposure at the point the subject actually sees the variant, not when the flag is evaluated. Evaluating a flag for a component that never renders inflates the denominator and dilutes every result you measure.

Caching and staleness

The SDK caches the resolved set and refreshes periodically. A flag flip propagates within the refresh interval.

If you need a flag to be a genuine kill switch, set a short refresh for that page and test the real path — measure how long it takes for a running client to see the change.

GitHub flag scan

AccelerUp scans repositories for flag usages, so a flag can be checked for references before it is deleted.

Tip

Delete flags. A codebase with two hundred permanently-on flags has two hundred untested branches and a growing evaluation cost. The scan tells you which are safe to remove.

Where this behaviour lives: backend/internal/handler/ab_config_handler.go. If the code and this page disagree, the code is right — please fix the page.

Part of Feature flagsShipping code dark, then turning it on for a percentage of people.