MainSDK
Search⌘K
How-to

Roll out a feature with a flag

Turn a feature on for some users and change it while the app runs.

Preview

Status Status is where the work is: Planned (in a milestone, not started), Building (tickets in progress), Preview (usable, may change), then the stability it ships at.

Stability The promise an interface ships with.

  • Stable Follows semantic versioning; breaking changes need a new major, 12 months of overlap and a codemod.
  • Beta Usable in production; may change before it becomes stable.
  • Experimental May change or go away; needs an explicit opt-in in main.yaml.
Stability levels
Updated 2026-10-28

You will add a flag, check it in code and change it with no deploy. It takes about 10 minutes.

You need

1. Define the flag

Set flags.new-checkout in your config store:

json
{ "enabled": true, "rollout": 10 }

2. Check it

app/checkout/choose.ts
import { flags } from "mainsdk";

export function checkoutFor(userId: string) {
  const rows = flags.value("export.row-limit", 500, { user: userId });
  return flags.enabled("new-checkout", { user: userId }) ? { checkout: "new", rows } : { checkout: "classic", rows };
}

The check reads memory only, and the same user gets the same answer on every instance.

3. Change it live

Set rollout to 50, or enabled to false. Every instance applies it with no restart, and the change is audited.

Check it worked

About 10 percent of users see the new checkout, and setting enabled: false turns it off for everyone.

Next

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet