Environment Management Pattern
Manage multiple deployment environments with validated configuration, feature flags, secret management, and preview database isolation.
What's Included#
- Zod-validated environment variable schema with typed access and startup validation
- Environment file structure (.env.local, .env.test, .env.example) with clear conventions
- Environment-aware configuration for feature flags, rate limits, and debug modes
- Dynamic base URL resolution for Vercel preview, production, and local environments
- Feature flags by environment with gradual production rollout support
- GitHub Actions environment secrets and Vercel environment configuration
Usage#
Via CLI#
Loading code block...
Via AI Assistant#
Ask your AI assistant:
- "Use the environment management pattern from Bootspring"
- "Apply the Bootspring environment management pattern to my project"
Key Considerations#
- Validate all environment variables at startup with Zod to fail fast on misconfiguration
- Never commit secrets to version control; use .env.local and CI/CD secret stores
- Keep environments as similar as possible to minimize environment-specific bugs
- Use isolated preview databases per branch to avoid polluting staging data
- Keep .env.example up to date so new developers can onboard quickly
Related Patterns#
- CI/CD - Deployment pipelines
- Docker - Container configuration
- Monitoring - Production monitoring