Feature Flags
Feature flags are the core of Basestack Feature Flags. They allow you to control feature rollouts, test new functionality, and manage feature availability across different environments. This guide covers everything you need to know about creating and managing feature flags.
What Are Feature Flags?
Feature flags (also called feature toggles) are:
- Switches - Enable or disable features without code changes
- Environment-Specific - Different states for dev, staging, and production
- Configurable - Include payloads for additional configuration
- Time-Limited - Can have expiration dates
- Trackable - Activity history for all changes
Feature flags enable continuous deployment by allowing you to deploy code that's disabled by default, then enable it when ready.
Creating a Feature Flag
Open Create Flag Modal
Navigate to your project's Feature Flags page and click Create Feature Flag:
- From the toolbar at the top of the flags list
- From the empty state if you have no flags yet
The create flag modal opens with three tabs: Core, Advanced, and Activity.
Configure Core Settings
In the Core tab, configure the essential flag settings:
Feature Key (Required):
- A unique identifier for your flag
- Must be 1-150 characters
- Avoid spaces and special characters
- Example:
header_size,new_checkout_flow,dark_mode
Description (Optional):
- A brief description of what the flag controls
- Maximum 120 characters
- Helps team members understand the flag's purpose
Enabled Environments:
- Select which environments should have this flag enabled
- You can enable/disable per environment
- Each environment can have different settings
Use descriptive feature keys that clearly indicate what the flag controls. This makes it easier to find and manage flags later.
Configure Advanced Settings (Optional)
In the Advanced tab, configure additional options:
Expiration Date:
- Set when the flag should automatically expire
- Useful for temporary features or A/B tests
- Format: dd/mm/yyyy
Payload:
- JSON object with additional configuration
- Can include any data your application needs
- Example:
{"theme": "dark", "size": "large"}
Payloads are useful for feature flags that need configuration beyond just enabled/disabled. For example, a theme flag might include color values.
Create the Flag
Click Create to create your feature flag. The flag will be created with the settings you configured for each selected environment.
Once created, you can immediately use the flag in your application using one of our SDKs.
Managing Feature Flags
Viewing Flags
The Feature Flags page displays all flags in your project. You can:
- View as Cards - Visual card layout with flag details
- View as Table - Compact table view for quick scanning
- Switch Views - Toggle between card and table views
Each flag card/row shows:
- Flag name (feature key)
- Description
- Creation date
- Enabled/disabled status per environment
- Quick actions (Edit, Delete, Activity)
Searching and Filtering
Use the search bar in the toolbar to:
- Filter by Name - Find flags by their feature key
- Real-time Search - Results update as you type
- Clear Search - Reset to show all flags
Editing Flags
To edit a flag:
- Click Edit on the flag card/row
- Modify settings in the modal (same tabs as creation)
- Click Update to save changes
Changes to flags are immediately available through the API. Your application will receive updated flag values on the next fetch.
Deleting Flags
To delete a flag:
- Click Delete on the flag card/row
- Confirm the deletion in the modal
- Review the warning about permanent deletion
Deleting a flag is permanent and cannot be undone. All associated comments, activity, and collaborator associations will be removed.
Viewing Flag Activity
Click Activity on any flag to see:
- Creation history
- All updates and changes
- Who made each change
- Timestamps
- Previous values
This is useful for:
- Auditing changes
- Understanding flag evolution
- Debugging issues
- Compliance requirements
Flag States Per Environment
Each flag can have different states in different environments:
- Development - Enable for testing
- Staging - Test before production
- Production - Control rollout to users
Use different flag states across environments to safely test features before enabling them in production.
Flag Payloads
Payloads allow you to include additional configuration with your flags:
Example Payloads
Theme Configuration:
{
"theme": "dark",
"primaryColor": "#000000",
"fontSize": "16px"
}Feature Configuration:
{
"maxItems": 10,
"sortOrder": "desc",
"showPreview": true
}A/B Test Variant:
{
"variant": "B",
"discount": 0.15,
"message": "Special Offer!"
}Payloads must be valid JSON. Use the JSON editor in the Advanced tab to create and validate your payload.
Best Practices
Naming Conventions
- Use Descriptive Names -
new_checkout_flowis better thanflag_1 - Use Snake Case -
header_sizeinstead ofheaderSizeorHeader Size - Be Consistent - Follow a naming pattern across your project
- Include Context -
mobile_dark_modeis clearer thandark_mode
Flag Lifecycle
- Create - Create the flag disabled in production
- Develop - Enable in development for testing
- Test - Enable in staging for QA
- Rollout - Gradually enable in production
- Monitor - Watch for issues and usage
- Cleanup - Delete flags that are no longer needed
Environment Strategy
- Development First - Always test flags in development
- Staging Validation - Verify in staging before production
- Gradual Rollout - Enable flags gradually in production
- Monitor Closely - Watch metrics when enabling flags
Payload Management
- Keep It Simple - Don't overcomplicate payloads
- Document Structure - Document expected payload structure
- Validate in Code - Validate payloads in your application
- Version Payloads - Consider versioning for breaking changes
Integration
After creating flags, integrate them into your application:
- Get Your Keys - Copy project and environment keys from Settings → General
- Install SDK - Install the appropriate SDK for your stack
- Initialize - Configure the SDK with your keys
- Use Flags - Check flag states in your code
See the JavaScript SDK documentation for detailed integration instructions for your technology stack.
Common Use Cases
Gradual Feature Rollout
- Create flag disabled in production
- Enable for internal testing
- Enable for beta users
- Enable for all users
A/B Testing
- Create flag with variant payload
- Enable for percentage of users
- Measure results
- Roll out winning variant
Emergency Kill Switch
- Create flag for critical feature
- Keep it easily accessible
- Disable immediately if issues arise
- Fix and re-enable
Environment-Specific Features
- Create flag enabled in development
- Keep disabled in production
- Use for debugging and testing
- Enable in production when ready
Next Steps
Now that you understand feature flags: