All docs pages
Docs

Feature flags

Turn parts of the app on for some visitors first, and compare the results in Traffic.

In stackly.json and the CLI it is feature-flags. It has no price of its own; see What features cost.

feature-flags · optional · needs backend · Stackly settings and analytics

Turn a part of the app on for some visitors first, and compare the results in Traffic.

Turn it on

"features": ["backend", "feature-flags"],
"settings": [
  { "key": "flag-new-checkout", "feature": "feature-flags", "label": "New checkout", "type": "number", "default": 0,
    "description": "Share of visitors, 0 to 100, who see the new checkout." }
]

Use it

import { flag, flags } from "#/lib/flags.server";

if (await flag("new-checkout", visitorId)) {
  // new checkout
}
const on = await flags(["new-checkout", "dark-header"], visitorId); // { "new-checkout": true, … }
  • A number flag is the share of visitors in percent; a boolean flag is on or off for everyone.
  • The same visitor always lands on the same side. Raising 10 to 30 keeps the first 10 percent in. Use a signed-in user's id, or a random id kept in a cookie.
  • Compare the sides in Traffic: track(on ? "checkout_done.new" : "checkout_done.old").

In Stackly

The owner moves each flag on the Feature flags page; the change reaches the next request without a rebuild.

Locally

stackly dev uses each flag's default.

All app features