Environments
Feature Flags supports environment-specific values directly in code.
checkoutV2: flag.boolean({ default: false, environments: { preview: true, staging: true, prod: false, },})Good uses for environment overrides
Section titled “Good uses for environment overrides”- 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.
Good habits
Section titled “Good habits”- 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.
Evaluation with environment context
Section titled “Evaluation with environment context”Pass the environment when you read a flag:
const enabled = await flags.enabled("checkoutV2", { environment: "prod",})When you leave environment out, Layeron evaluates the rules and then uses the
flag default.
Promotion workflow
Section titled “Promotion workflow”A common flow looks like this:
- Add the flag and default in code.
- Turn the flag on in preview.
- Add tenant or user rules.
- Roll out by percentage.
- Set production to the final value.
Keep the same flag key through each step so the rollout stays readable in code and in history.