Environment Variables & Secrets Management
Configure your SaaS safely across environments by managing secrets, separating public and private variables, and avoiding leaking keys to the client.
Why Configuration Matters
A SaaS connects to databases, payment providers, and AI APIs — each with keys that differ per environment. Environment variables keep them out of code so one codebase runs anywhere.
The .env File
Local config lives in a .env file as plain key-value pairs. It's loaded at startup and must never be committed to git.
DATABASE_URL=postgresql://localhost/app
STRIPE_SECRET_KEY=sk_test_123
OPENAI_API_KEY=sk-abcAll lessons in this course
- Intro to SaaS & AI Synergy
- Choosing Your Tech Stack
- Project Initialization & Structure
- Environment Variables & Secrets Management