Feature flag
A feature flag is a runtime switch that turns a piece of functionality on or off for some or all users without deploying new code.
A feature flag wraps a code path in a condition whose value comes from configuration. The code for the new behavior is deployed to production and stays inactive until the flag is turned on. This separates two events that used to be one: deploying code and releasing a feature.
Flags can be evaluated globally, per environment, per customer or for a percentage of users. The values usually come from a flag service or a configuration endpoint, so they can change without a build.
Example
During a migration, the new Angular version of the orders screen is deployed next to the old one. A flag decides which one a user gets:
const routes: Routes = [
{
path: 'orders',
canMatch: [() => inject(FlagService).isOn('new-orders')],
loadComponent: () =>
import('./orders/orders.component').then(m => m.OrdersComponent),
},
{ path: 'orders', component: LegacyOrdersWrapperComponent },
];
The team enables new-orders for internal users first, then for one customer, then for everyone. If a problem appears, turning the flag off restores the old screen without a deployment.
Common misunderstanding
Flags are often seen as free. Each flag doubles the paths through a piece of code, and both paths need testing. Flags that stay after the rollout turn into permanent configuration that nobody dares to remove. Give every flag an owner and a removal date, and delete both the flag and the old path once the rollout is complete.
A flag also cannot undo everything. If the new path wrote data in a new format, switching back needs a plan for that data. See migrating without downtime for how flags fit a route-by-route migration.
Why it matters. Flags let migrated screens reach production early and be shown to users gradually, with a fast way back to the legacy screen if something goes wrong.
Related terms
Planning a migration or a micro-frontend platform?
In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.
Message me on LinkedIn