Flags and environments

Create flags, switch them on and off, and keep development and production apart. Plus how the SDK decides which environment to read.

Create a flag

On the Feature flags page, click New flag and fill in:

  • Flag name: the name you check in code, for example new-checkout, 3 to 50 characters. Your code uses it exactly as you type it.
  • Flag description: a note for your team about what the flag does, 10 to 300 characters.
  • Environment: Development or Production.

Click Create flag. New flags start switched off.

Flagpole, the free plan, includes 10 flags per environment: up to 10 in Development and 10 in Production. A flag you use in both environments counts once in each. Full Mast has no limit.

If an environment in a Flagpole project has more than 10 flags, for example after moving down from Full Mast, every flag switch and rollout in that environment is locked. Delete flags there until it has 10 or fewer, or upgrade, to unlock them.

Switch a flag on or off

Each flag has a switch. Flip it, and the change reaches your app within about 30 seconds, with no redeploy. The SDK caches flags for 30 seconds, so a server picks up the change on its next refresh, and a browser on its next page load.

A flag that’s off is off for everyone. A flag that’s on is on for everyone, unless it’s in a percentage rollout.

While a flag is in an active schedule, it’s locked until the schedule ends or you remove it: its switch and its ⋯ menu are disabled, and so are the same controls in its panel, so you can’t edit it, delete it or start a rollout.

See everything about a flag

Click a flag’s name to open its panel. It shows the flag in the environment you’re looking at:

  • its switch, its rollout and its groups, which you can change from here
  • when a running schedule next turns it on or off
  • the same flag in the other environment, for example “In Development: on · everyone”, with Open to jump to it. If it isn’t there yet, Create in Development opens the new flag form with the name and description filled in.
  • how many people it reached each day for the last week, its latest changes, and its schedules. These need Full Mast.
  • the code to check it, for example useFlag('new-checkout'), and when your app last connected

The panel has its own link, so you can send it to a teammate. Close it with Esc or the close button.

Edit or delete a flag

From the ⋯ menu on a flag, or from its panel:

  • Edit flag (Edit details in the panel) changes the name or description in both environments at once, so the two never drift apart. The new name can’t belong to another flag. If you rename a flag, update your code too: the SDK looks flags up by name, so checks for the old name stop finding it.
  • Delete flag (Delete from Production or Delete from Development in the panel) removes it from that environment for good. The flag with the same name in the other environment stays. Checks for the deleted flag then get your fallback or default, or false.

Environments

Every project has two environments: Development and Production. Use the Environment switcher on the Feature flags page to move between them.

A flag belongs to one environment. To use new-checkout in both, create it in each. They’re separate flags with the same name, so you can switch it on in development and leave it off in production. Their name and description stay in step, because editing one changes both.

Which environment the SDK reads

Each SDK instance reads one environment. It picks the first of these that’s set:

  1. the env option: 'production' or 'development'
  2. the FLAGGISH_ENV environment variable
  3. the NEXT_PUBLIC_FLAGGISH_ENV environment variable
  4. Production if NODE_ENV is production, otherwise Development

So by default, next dev reads Development flags and a production build reads Production.

The variables take production or development, in any case. Other values are ignored.

Reading production flags from staging

A staging deploy usually runs with NODE_ENV=production, so it reads Production flags. To point it at Development flags instead, set:

.env
NEXT_PUBLIC_FLAGGISH_ENV=development

The same works the other way: set production to test production flags against a local build. In Next.js, browser code only sees NEXT_PUBLIC_ variables, so use that name to cover both the server and the browser. See Environment variables.

Rollouts in each environment

Because each environment has its own copy of a flag, each has its own rollout. A user in a 10% rollout in development isn’t necessarily in the 10% in production.

Was this page helpful?

Request early access

Become a beta user, or stay up to date with the project.