Skip to content

Environments

Feature Flags supports environment-specific values directly in code.

Terminal window
checkoutV2: flag.boolean({
default: false,
environments: {
preview: true,
staging: true,
prod: false,
},
})
  • Turn on a feature in preview before production.
  • Keep a safe fallback in production.
  • Raise limits in one environment while keeping another smaller.
  • Change copy, labels, or small UI behavior by environment.
  • Keep preview and staging close to production when you want confidence.
  • Keep production defaults conservative.
  • Use environment overrides for app-wide behavior, then add rules for finer targeting.

Pass the environment when you read a flag:

Terminal window
const enabled = await flags.enabled("checkoutV2", {
environment: "prod",
})

When you leave environment out, Layeron evaluates the rules and then uses the flag default.

A common flow looks like this:

  1. Add the flag and default in code.
  2. Turn the flag on in preview.
  3. Add tenant or user rules.
  4. Roll out by percentage.
  5. Set production to the final value.

Keep the same flag key through each step so the rollout stays readable in code and in history.