Node.js › Cloud & DevOps
What is a feature flag, and how would you implement one in a Node.js application to control a new feature's rollout?
IntermediateAnswer
A feature flag is a runtime conditional determining whether code executes, letting a feature deploy dormant and be enabled gradually without a new deployment -- decoupling deploying code from releasing features, enabling instant rollback by flipping the flag off.
if (await isFeatureEnabled('new-checkout-flow', req.user)) {
return renderNewCheckout(req, res);
}
renderLegacyCheckout(req, res);Real-world example A team rolls out a redesigned checkout behind a flag enabled first for employees, then 1%, 10%, and 100% of customers, able to instantly disable it if conversion rates dropped.