Skip to main content
Properly configuring environments helps you organize issues, filter noise, and apply environment-specific settings.

Setting the Environment

The environment option identifies where your code is running:

Using Environment Variables

Common environment names: production, staging, development, qa, test

Environment-Specific Configuration

Conditional Initialization

Only initialize Sentry in certain environments:

Different Settings Per Environment

Environment Variables

Node.js

Browser (with Build Tools)

Using Webpack DefinePlugin or similar:
Then in your code:

Vite

Vite automatically exposes environment variables prefixed with VITE_:

Development vs Production

Disabling in Development

Disabling Sentry in development means you won’t catch development-only bugs. Consider using filtering instead.

Development-Specific Settings

Browser Extension Detection

The Browser SDK automatically detects browser extensions and disables itself by default:

Multiple Environments in the Same Project

Use environments to segment data in your Sentry project:
Then in Sentry’s UI, filter by environment to see only relevant issues.

Server-Side Environment Detection

Express.js

Cloud Platforms

Vercel

AWS Lambda

Netlify

Framework-Specific Configuration

Next.js

Next.js supports .env.local, .env.production, etc.:

SvelteKit

Best Practices

Choose a standard set of environment names and use them consistently across all your projects. Common choices:
  • production
  • staging
  • development
  • qa / test
Never commit DSN or other sensitive configuration to source control. Use environment variables:
Production environments may need lower sampling rates to control volume:
Debug mode helps troubleshoot SDK issues during development:

Next Steps

Sampling Configuration

Control data volume with sampling rates

Filtering Events

Filter events before sending to Sentry