How to Manage CMS Environment Variables
IntermediateQuick Answer
TL;DR
Managing content management system environment variables means securely storing and accessing configuration values—API keys, project IDs, dataset names, and tokens—across development, staging, and production environments. Use `.env` files locally, your hosting platform's environment variable settings for deployed environments, and never commit secrets to version control. Separate read-only tokens for frontends from write tokens for server-side operations.
Key Takeaways
- Never commit API keys, tokens, or secrets to version control—use `.env` files locally and platform secrets for deployments
- Separate read-only (CDN) tokens from write tokens; frontends only need read access
- Use environment-specific values for project IDs, dataset names, and API endpoints (dev, staging, production)
- Follow framework conventions: `NEXT_PUBLIC_` prefix for Next.js client-side variables, `import.meta.env` for Vite
- Rotate tokens regularly and audit which services have write access