Skip to content

Environments

Environments let you have different flag values for development, staging, and production.

What Are Environments?

An environment is a separate context where the same flag can have different values. Each environment has its own API key.

EnvironmentPurposeTypical Use
DevelopmentLocal devAll flags ON for testing
StagingQA testingTest before production
ProductionReal usersCareful, gradual rollouts

Example

The same flag can have different states across environments:

Flag: new-checkout-flow
┌─────────────┬─────────┬────────────┐
│ Environment │ Enabled │ Percentage │
├─────────────┼─────────┼────────────┤
│ Development │ ✅ ON │ 100% │ ← Always on for devs
│ Staging │ ✅ ON │ 100% │ ← QA is testing it
│ Production │ ✅ ON │ 10% │ ← Slowly rolling out
└─────────────┴─────────┴────────────┘

API Keys

Each environment has its own API key:

EnvironmentAPI Key Prefix
Developmentfs_dev_...
Stagingfs_staging_...
Productionfs_prod_...

Use the appropriate key for each environment:

development
const featsync = new Featsync({
apiKey: process.env.FEATSYNC_DEV_KEY, // fs_dev_...
});
production
const featsync = new Featsync({
apiKey: process.env.FEATSYNC_PROD_KEY, // fs_prod_...
});

Creating Environments

  1. Open your project in the dashboard
  2. Click Environments in the header
  3. Click New Environment
  4. Enter a name (e.g., “Staging”)
  5. Copy the new API key

Workflow

A typical workflow using environments:

1. Development

Enable the flag at 100% in Development. Test your feature locally.

.env.local
FEATSYNC_API_KEY = fs_dev_xxxxx;

2. Staging

Enable in Staging for QA testing. Maybe run some automated tests.

.env.staging
FEATSYNC_API_KEY = fs_staging_xxxxx;

3. Production Rollout

Gradually roll out in Production:

  • Enable at 10%
  • Monitor metrics
  • Increase to 25%, 50%, 100%
.env.production
FEATSYNC_API_KEY = fs_prod_xxxxx;

Environment Variables

Set the appropriate API key per environment using environment variables:

Next.js

.env.local (development)
FEATSYNC_API_KEY=fs_dev_xxxxx
.env.production
FEATSYNC_API_KEY=fs_prod_xxxxx

Docker / CI

docker-compose.yml
services:
app:
environment:
- FEATSYNC_API_KEY=${FEATSYNC_API_KEY}

Platform-Specific

Most hosting platforms (Vercel, Netlify, Heroku) let you set environment variables per deployment environment.

Free Tier

On the Free tier, you have access to:

  • 1 environment (Production)
  • 1 API key

Upgrade to Pro for:

  • Unlimited environments
  • Create Development, Staging, or any custom environments

Best Practices

1. Use Different Keys Per Environment

Never use your production key in development:

// Good
const apiKey = process.env.FEATSYNC_API_KEY;
// Bad - hardcoded production key
const apiKey = 'fs_prod_abc123';

2. Enable Flags in Dev First

Test features in Development before enabling in Staging or Production.

3. Use Staging for QA

Before any production rollout, validate in Staging with real-ish data.

4. Roll Out Gradually in Production

Start small (5-10%), monitor, then increase.

Next Steps