---
title: "Roll out a feature with a flag"
description: "Turn a feature on for some users and change it while the app runs."
section: "guides"
status: "Preview"
spec: "flags"
canonical: "https://mainsdk.dev/docs/guides/roll-out-with-flags"
updated: "2026-10-28"
---

# Roll out a feature with a flag

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

Status: Preview · Canonical: https://mainsdk.dev/docs/guides/roll-out-with-flags · 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

- A config store (see [Change config without a deploy](https://mainsdk.dev/docs/guides/change-config-without-a-deploy)).

## 1. Define the flag

Set `flags.new-checkout` in your config store:

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

## 2. Check it

```ts title="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

- [Feature flags](https://mainsdk.dev/docs/interfaces/flags)
- [Plans and entitlements](https://mainsdk.dev/docs/interfaces/entitlements): for features a plan includes.
