Why You Should Use Feature Flags and What They Are

Just a guy who loves to write code and watch anime.
Search for a command to run...

Just a guy who loves to write code and watch anime.
No comments yet. Be the first to comment.
Qualities that make outstanding builders.

Bipedal vs quadrupedal: how many legs This is about the number of legs the creature walks on. Bipedal. Two legs. Humans, ostriches, T-rex, kangaroos, most fantasy humanoids. Quadrupedal. Four legs. Do

Intro You hear "lerp" and "smoothstep" everywhere in game dev. They sound like math jargon. They're not. Both are small tools that do the same job: smoothly move from one value to another. The problem

What is Kinematics Kinematics is the math field. It's the study of how things move without worrying about forces (which would be dynamics). FK and IK are the two branches: forward kinematics and inver

Intro Textures are usually the biggest cost in a 3D scene. Memory, bandwidth, and load time all get eaten by them. Resizing them is the obvious lever. There's more. This post is about the less obvious

Ever launched a feature and then wished you hadn't? Or wanted to test a new feature with just 10% of your users to test it out before rolling it out to everyone?
Feature flags can help.
Feature flags are like switches in your code that can turn features on or off. They are conditional statements that let you change features without having to redeploy your application.
// Without feature flags
function showNewDesign() {
return <NewDesign />;
}
// With feature flags
function showNewDesign() {
if (isFeatureEnabled("new-design")) {
return <NewDesign />;
}
return <OldDesign />;
}
Kill Switch: Have you ever released code that let users make free purchases by mistake? A feature flag lets you quickly turn off these features without needing a deployment.
Gradual Rollouts: Try out new features with a small group of users (like 10% of your users) to see how they work and find problems early.
Beta Testing: Allow certain users to try new features while keeping them hidden from everyone else.
Safe Refactoring: Test new versions of your code alongside the old ones without impacting users.
function fetchUsers() {
const users = await oldQuery();
if (isFeatureEnabled("new-query")) {
const newUsers = await newQuery();
// Compare results, log differences
return users;
}
return users;
}
const flags = {
newDesign: process.env.ENABLE_NEW_DESIGN === "true",
};
Pros: Simple, no infrastructure needed
Cons: Requires deployment to change, limited to boolean flags
interface FeatureFlag {
name: string;
enabled: boolean;
rolloutPercentage?: number;
enabledForUsers?: string[];
}
Pros: Dynamic updates, complex rules possible
Cons: Requires database setup, potential performance impact
Services like LaunchDarkly, Posthog or ConfigCat
Pros: Full-featured, managed solution
Cons: Cost, vendor lock-in
The aim isn't to use feature flags everywhere, but to apply them strategically where they provide the most value.