Skip to main content

Environments

Environments in Toggly allow you to manage feature flags separately for different stages of your development lifecycle.

What are Environments?

Environments are isolated configurations for feature flags. Each environment maintains its own:

  • Feature flag states (enabled/disabled)
  • Targeting rules and segments
  • Experiment configurations

Default Environments

When you create a new application, Toggly automatically creates a set of default environments (configured in your Workspace Settings). You can always add, edit, or remove environments later.

Common default environments include:

Development

Use for local development and testing. Changes here don't affect production users.

Staging

Use for pre-production testing with production-like data. Perfect for QA and stakeholder reviews.

Production

Your live environment serving real users. Changes here affect all production traffic.

Creating Custom Environments

You can create additional environments for:

  • Beta: Testing with a subset of production users
  • Regional: Different configurations per region
  • Customer-specific: Custom environments for enterprise customers

To create a custom environment:

  1. Navigate to SettingsEnvironments
  2. Click Create Environment
  3. Enter a name and description
  4. Configure environment-specific settings
  5. Click Create

App Keys & Environments

App Keys are used to connect your application to Toggly. When you generate an App Key, you can choose to restrict it to specific environments (e.g., a "Production Only" key).

  • Best Practice: Create separate App Keys for each environment (e.g., one for Staging, one for Production) to prevent accidental cross-environment access.

Use the appropriate key for each environment:

const environment = process.env.NODE_ENV || 'development';
// Ensure this key is restricted to the current environment
const appKey = process.env.TOGGLY_APP_KEY;

const toggly = new TogglyClient({
appKey,
environment
});

Syncing & Comparing Environments

Toggly provides a powerful Compare Environments tool that lets you visualize differences between any two environments (e.g., Staging vs. Production).

Using the comparison tool, you can:

  1. View Differences: See exactly which flags or rules differ between environments.
  2. Sync Changes: Selectively copy feature states and configurations from one environment to another.
  3. Audit Safety: Review changes before applying them to a critical environment like Production.
Production Safety

Always test feature flags in Development and Staging before promoting to Production. Use gradual rollouts even after promotion.

Environment Isolation

Environments are completely isolated:

  • Changes in Development don't affect Production
  • Each environment has separate metrics and analytics
  • App keys can be restricted to specific environments for added security
  • Audit logs track all changes across all environments, with filtering capabilities

Best Practices

  1. Use Environment Variables: Store App Keys in environment variables, not in code
  2. Match Your Deployments: Align Toggly environments with your deployment environments
  3. Test Before Production: Always test feature flags in non-production environments first
  4. Document Differences: Note any environment-specific configurations or requirements

Next Steps