# Feature Flags

> The Feature Flags is a technique that allows turning features on or off without deploying new code.

## What are feature flags and how do they work?

The technique of wrapping functionality in conditions controlled by configuration. Allows deploying unfinished code safely, rolling out features gradually, running A/B tests and quickly disabling broken functionality.

- Topic: Practices
- Type: technique

## Example

Wrong:

```js
if (user.email.endsWith('@acme.com')) {
  showNewCheckout();
}
```

Right:

```js
if (flags.isEnabled('new-checkout', { userId: user.id })) {
  showNewCheckout();
}
```

A named flag with a default can be switched or rolled out gradually without editing and deploying code.

## Common mistakes

- Leaving old flags in code for months, so nobody knows which branch is live.
- Flag state flickering on page load because flags are fetched after the first render.

## Key points

- Every flag has a safe default value used when the flag service is unreachable.
- Access to paid or private features is checked on the server, a client-side flag alone is not a security control.
- Flags that are fully rolled out are removed along with the dead code path.

## Interview questions

### Feature flag vs config setting: what is the difference?

A config setting is a long-term option. A feature flag is usually temporary and is removed once the feature is fully released.

### Do feature flags slow down an app?

Barely, if flags are evaluated locally from a cached rule set rather than with a network call each time.

### What is a kill switch flag?

A flag that turns off a risky feature instantly in production without a deploy, used when something goes wrong.

## Related cards

- [Trunk-Based Development](https://wonderium.dev/processes/trunk-based-development.md)
- [Deployment](https://wonderium.dev/processes/deployment.md)
- [CI / CD](https://wonderium.dev/processes/ci-cd.md)
- [Release](https://wonderium.dev/processes/release.md)
- [Technical Debt](https://wonderium.dev/processes/technical-debt.md)

---

- Level: [Processes](https://wonderium.dev/processes.md)
- HTML version: https://wonderium.dev/processes/feature-flags
- Last updated: 2026-11-25
