Skip to main content

Creating a Feature Flag

Learn how to create and configure feature flags in the Toggly dashboard.

Quick Create

The fastest way to create a feature flag:

  1. Navigate to Features in the dashboard
  2. Click Create Feature Flag
  3. Enter a feature key (e.g., new-checkout-flow)
  4. Click Create

The feature flag will be created with default settings and disabled state.

Detailed Creation

For more control, use the detailed creation form:

Step 1: Basic Information

  • Feature Key: Unique identifier (required)

    • Use kebab-case: new-checkout-flow
    • Must be unique within the environment
    • Cannot be changed after creation
  • Name: Human-readable name (optional)

    • Display name in the dashboard
    • Can be changed later
  • Description: Detailed description (recommended)

    • Explain what the feature does
    • Include context and use cases
    • Helpful for team members

Step 2: Feature Type

Choose the feature flag type:

  • Boolean: Simple on/off switch
  • Multi-Variant: Returns different values (variants)

For multi-variant flags, define variants:

  • Control: Default variant (e.g., control)
  • Variant A: First treatment (e.g., red-button)
  • Variant B: Second treatment (e.g., blue-button)
  • Variant C: Additional variants as needed

Step 3: Initial State

Set the initial state:

  • Enabled: Feature is active (use with caution)
  • Disabled: Feature is inactive (recommended)
Start Disabled

Always start with the feature disabled. Enable it after configuring targeting rules and testing.

Step 4: Targeting Rules

Configure who sees the feature:

  • All Users: Enable for everyone
  • Percentage: Enable for X% of users
  • Segments: Enable for specific user segments
  • Custom Rules: Complex targeting conditions

Step 5: Environment

Select the environment:

  • Development: For local development
  • Staging: For pre-production testing
  • Production: For live users

Feature Key Best Practices

Naming Conventions

Use descriptive, consistent naming:

// Good examples
'new-checkout-flow'
'enhanced-search-results'
'premium-dashboard'
'beta-mobile-app'

// Bad examples
'feature-1'
'new-thing'
'flag-abc'

Organization

Use prefixes or tags to organize:

  • frontend-*: Frontend features
  • backend-*: Backend features
  • experiment-*: Experimental features
  • critical-*: Critical features

Multi-Variant Flags

Multi-variant flags return different values instead of just true/false:

Creating Variants

  1. Select Multi-Variant as the feature type
  2. Click Add Variant
  3. Enter variant key (e.g., red, blue, green)
  4. Add variant description
  5. Repeat for each variant

Variant Distribution

Configure how variants are distributed:

  • Equal Distribution: Each variant gets equal traffic
  • Weighted Distribution: Assign custom weights
  • Targeted Distribution: Assign variants to segments

Example:

// Variant distribution
control: 50% // 50% of users see control
red: 25% // 25% see red variant
blue: 25% // 25% see blue variant

Targeting Configuration

All Users

Enable the feature for everyone:

Targeting: All Users
No additional configuration needed

Percentage Rollout

Gradually roll out to a percentage:

Targeting: Percentage Rollout
Percentage: 25% # Enable for 25% of users

User Segments

Target specific segments:

Targeting: User Segments
Segments:
- premium-users
- beta-testers

Custom Rules

Create complex targeting:

Targeting: Custom Rules
Rule: (plan = 'premium' AND country = 'US') OR (plan = 'enterprise')

After Creation

Once created, you can:

  1. Test the Flag: Use the SDK to evaluate the flag
  2. Configure Targeting: Set up targeting rules
  3. Monitor Metrics: Watch usage in the dashboard
  4. Enable When Ready: Enable after testing

Example: Complete Feature Flag

Here's an example of a fully configured feature flag:

Feature Key: new-checkout-flow
Name: New Checkout Flow
Description: Redesigned checkout experience with improved UX
Type: Boolean
State: Disabled
Environment: Production

Targeting:
Type: Percentage Rollout
Percentage: 10%
Segment: premium-users (optional)

Tags:
- frontend
- checkout
- experiment

Next Steps