TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Do you have a guide on how to use feature flags?

8 pointsby victor_eabout 3 years ago
I've seen lots of posts on HN saying that feature flags are a must use. How do you use them?

5 comments

dabeeeensterabout 3 years ago
We[4] have a few[1] guide[2] articles[3] in our docs which might give people some ideas on how they can be used.<p>[1] <a href="https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;mobile-app-versioning" rel="nofollow">https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;mobile-app-ve...</a><p>[2] <a href="https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;staged-feature-rollouts" rel="nofollow">https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;staged-featur...</a><p>[3] <a href="https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;testing-push-notifications" rel="nofollow">https:&#x2F;&#x2F;docs.flagsmith.com&#x2F;guides-and-examples&#x2F;testing-push-...</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;Flagsmith" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Flagsmith</a>
jaredsohnabout 3 years ago
The easiest way to do it is to create environment variables and check against them in code. This allows turning on &#x2F; off functionality globally. Systems like AWS and Heroku allow toggling them without redeploying.<p>You can also create features that apply to individual users or if enterprise then to all users in the customer. This can be done by creating some boolean fields in the database (using a single feature_flags json field is recommended because then you don&#x27;t have to change the schema every time a new feature flag is added.)<p>And then in code you check against the environment variable or against the user &#x2F; customer before running changed functionality via a simple if statement.
swahabout 3 years ago
The idea is that for some particular new feature&#x2F;behaviour&#x2F;optimization your application has, instead of just coding it, code it in a way that can be disabled easily:<p>For example, I have some projects using using redux-saga, I&#x27;ll do something like:<p><pre><code> if (env.EnableSomeNewThing) { yield fork(saga1) } </code></pre> So this behavior can be enabled&#x2F;disabled using an env variable instead of commenting&#x2F;reverting code from Git. Of course this could also be more sophisticated: enable via configuration, enable for a sample of the users, or premium users...
efortisabout 3 years ago
I export a boolean such as `hasFeatureX` and then delete it.<p><pre><code> if (hasFeatureX) doX() else … </code></pre> If it has to be more complex than that, I use a feature branch.
Valordabout 3 years ago
Check out some of the blog posts from <a href="https:&#x2F;&#x2F;launchdarkly.com&#x2F;blog&#x2F;" rel="nofollow">https:&#x2F;&#x2F;launchdarkly.com&#x2F;blog&#x2F;</a>