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.
| Environment | Purpose | Typical Use |
|---|---|---|
| Development | Local dev | All flags ON for testing |
| Staging | QA testing | Test before production |
| Production | Real users | Careful, 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:
| Environment | API Key Prefix |
|---|---|
| Development | fs_dev_... |
| Staging | fs_staging_... |
| Production | fs_prod_... |
Use the appropriate key for each environment:
const featsync = new Featsync({ apiKey: process.env.FEATSYNC_DEV_KEY, // fs_dev_...});const featsync = new Featsync({ apiKey: process.env.FEATSYNC_PROD_KEY, // fs_prod_...});Creating Environments
- Open your project in the dashboard
- Click Environments in the header
- Click New Environment
- Enter a name (e.g., “Staging”)
- Copy the new API key
Workflow
A typical workflow using environments:
1. Development
Enable the flag at 100% in Development. Test your feature locally.
FEATSYNC_API_KEY = fs_dev_xxxxx;2. Staging
Enable in Staging for QA testing. Maybe run some automated tests.
FEATSYNC_API_KEY = fs_staging_xxxxx;3. Production Rollout
Gradually roll out in Production:
- Enable at 10%
- Monitor metrics
- Increase to 25%, 50%, 100%
FEATSYNC_API_KEY = fs_prod_xxxxx;Environment Variables
Set the appropriate API key per environment using environment variables:
Next.js
FEATSYNC_API_KEY=fs_dev_xxxxxFEATSYNC_API_KEY=fs_prod_xxxxxDocker / CI
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:
// Goodconst apiKey = process.env.FEATSYNC_API_KEY;
// Bad - hardcoded production keyconst 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
- Learn about flag types
- Set up percentage rollouts
- View pricing for environment limits