Feature Flags
Feature flags are the core building block of Flagstack. They allow you to toggle functionality without deploying code.
What is a Feature Flag?
A feature flag is a toggle that controls whether a piece of functionality is enabled or disabled. Instead of deploying new code to change behavior, you simply flip a switch in the Flagstack dashboard.
Creating a Feature Flag
Create feature flags in the Flagstack dashboard by clicking New Feature. Each flag needs a unique key:
- Use lowercase letters, numbers, and underscores
- Be descriptive:
new_checkout_flowis better thanfeature1 - Keys cannot be changed after creation
Checking Feature Flags
Check if a feature is enabled using the Flagstack API:
# Simple boolean check
if Flagstack.enabled?(:new_checkout)
# Feature is enabled
end
# Check for a specific user
if Flagstack.enabled?(:new_checkout, current_user)
# Feature is enabled for this user
end
# Get all features
Flagstack.features.each { |f| puts f.key }
Flipper Compatible
Your existing Flipper.enabled? code works unchanged. Flagstack sets itself as the default Flipper instance.
Feature Flag States
A feature flag can be in one of several states:
Disabled (Off)
The feature is off for everyone. Flagstack.enabled? returns false.
Enabled (On)
The feature is on for everyone. Flagstack.enabled? returns true.
Conditional
The feature is enabled based on gates (actors, groups, percentages). See Gates & Targeting for details.
Best Practices
- Clean up old flags — Remove flags once a feature is fully rolled out
- Use descriptive names — Future you will thank present you
- Document flags — Add descriptions in the dashboard to explain what each flag controls
- Start disabled — New flags should be off by default until you're ready