Feature flags for web apps — what to use
Without feature flags, big features turn deploys into rituals with rollback drills. What to use for small and mid teams.
Without feature flags, every big feature ships the moment it's merged, and every deploy becomes a ritual with a rollback plan. Feature flags are switches in code that turn functionality on or off without a redeploy. They're a basic tool for:
- Safer deploys: canary releases and gradual rollouts.
- A/B testing.
- Kill switches for features that misbehave in production.
- Beta access for specific users or customers.
Not all flags are the same
It helps to name the type of each flag when you create it, because types have different lifetimes:
- Release flags hide unfinished work. They should live days or weeks and then be removed.
- Experiment flags split traffic for an A/B test. They end when the test ends.
- Ops flags (kill switches) disable an expensive or fragile feature under load. These can live long.
- Permission flags enable features per plan or per customer. These are really product configuration and often belong in your data model rather than a flag system.
Options
- LaunchDarkly. The established commercial option: mature SDKs, audit logs, approval workflows. Pricing is per seat or usage and changes, so check the current plans. It makes the most sense when many teams need governance.
- GrowthBook. Open source and self-hostable, with a hosted version too. Strong on A/B testing and works with your existing analytics data.
- PostHog feature flags. Bundled with PostHog analytics. Convenient if you already use PostHog, since flags and their effect live in one place.
- Unleash. Open source and self-hostable, with a commercial edition. Less polished interface, but it does the job.
- Custom. A flag table in your database plus a small admin screen. A basic version is quick to build. There's no experiment analysis out of the box.
A minimal custom setup looks like this:
CREATE TABLE feature_flags (
key text PRIMARY KEY,
enabled boolean NOT NULL DEFAULT false,
rollout_pct integer NOT NULL DEFAULT 0,
owner text NOT NULL,
remove_by date
);
-- stable bucketing: the same user always lands in the same bucket
-- enabled_for_user = hash(flag_key || user_id) % 100 < rollout_pct
Hashing the flag key together with the user ID gives each user a stable position per flag, so a 10% rollout really means the same 10% on every request, and raising it to 20% keeps the first group included.
How to choose
- Small team, a handful of flags, no experiments: custom table or a self-hosted open-source tool.
- You run product experiments regularly: GrowthBook or PostHog, so results and flags sit next to each other.
- Many teams, compliance, approval workflows: LaunchDarkly or a commercial edition of an open-source tool.
Switching later is possible but annoying, so wrap the provider behind a thin internal interface such as isEnabled(flag, user). The rest of the code shouldn't know which vendor answers.
Common mistakes
- Flags that never get removed. Years later the code has dozens of dead toggles and nobody remembers what they did.
- Reading flags on every request without caching. Every page load waits on a database or network call.
- Targeting by hand-picked user lists instead of stable bucketing or segments, so you can't roll out to "10% of users".
- No owner. Nobody decides when a flag is done and can go.
- Nested flags. Flag B only matters when flag A is on, and nobody tests that combination.
- Testing only one state. CI runs with the flag on; production runs with it off.
- Leaking unreleased features through client-side flags whose names and payloads anyone can read in the browser.
Checklist
- Every flag has a type, an owner and a removal date when it's created.
- Flag values are cached with a short TTL or streamed, not fetched per request.
- Rollouts use stable bucketing.
- Both states are covered by tests for any flag that guards critical paths.
- A monthly cleanup removes expired flags and their dead code paths.
Feature flags are cheap to add and expensive to forget. We set them up as part of web application development, and cleaning up flag debt is routine in ongoing web app support.
Want safer releases for your web app? Reach us on Telegram or MAX.
Got a project on this topic? Tell us the task — we'll come back with an estimate and a schedule.
Message on Telegram → Message on MAX