Environment Variables
Configure Starter Pro securely with production-ready environment variables for authentication, billing, database access, email delivery, and deployment infrastructure.
OverviewLink to section
Starter Pro uses environment variables to separate infrastructure, authentication, billing, email delivery, and deployment concerns safely.
This keeps:
- secrets outside the repository
- environments predictable
- deployments portable
- billing infrastructure secure
- authentication production-safe
Core principle
Environment variables define infrastructure boundaries between your codebase and production systems.
Production mindsetLink to section
Starter Pro is designed around real SaaS deployment requirements.
That means environment variables should support:
- local development
- staging deployments
- production infrastructure
- Stripe billing
- OAuth providers
- secure authentication
- database isolation
Secure by default
Deployment ready
Infrastructure separation
Mental modelLink to section
Public variables
Public variables are exposed to the browser and should only contain safe frontend values.
Application variablesLink to section
These variables define the application URL structure.
NEXT_PUBLIC_APP_URL=http://localhost:3000
APP_BASE_URL=http://localhost:3000NEXT_PUBLIC_APP_URL
- safe for frontend
- used client-side
- production domain
APP_BASE_URL
- server-only usage
- auth redirects
- internal references
Database configurationLink to section
Starter Pro uses PostgreSQL with Prisma.
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/starter_proRecommended production practices:
- managed PostgreSQL hosting
- automated backups
- staging and production separation
- connection pooling
- restricted database access
Production rule
Never share production database credentials across local environments or public repositories.
Authentication variablesLink to section
Starter Pro uses Auth.js for authentication.
AUTH_SECRET=
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=
AUTH_TRUST_HOST=trueRequiredLink to section
| Variable | Purpose |
|---|---|
AUTH_SECRET | Signs sessions and authentication tokens |
Optional providersLink to section
| Variable | Purpose |
|---|---|
AUTH_GOOGLE_ID | Google OAuth client ID |
AUTH_GOOGLE_SECRET | Google OAuth client secret |
AUTH_GITHUB_ID | GitHub OAuth client ID |
AUTH_GITHUB_SECRET | GitHub OAuth client secret |
NotesLink to section
AUTH_SECRETmust be strong in production- OAuth providers are optional
- Email/password auth works without OAuth
- Production domains must match OAuth configuration
Email deliveryLink to section
Starter Pro supports transactional email flows through Resend.
AUTH_RESEND_API_KEY=
AUTH_EMAIL_FROM="PyColors <noreply@your-domain.com>"Email flows include:
- verification emails
- password reset emails
- transactional auth delivery
Verification flows
Recovery flows
Stripe billing variablesLink to section
Starter Pro includes production-ready Stripe billing foundations.
STRIPE_SECRET_KEY=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_WEBHOOK_SECRET=
STRIPE_PRODUCT_PRO=
STRIPE_PRICE_PRO_MONTHLY=Core billing variablesLink to section
| Variable | Purpose |
|---|---|
STRIPE_SECRET_KEY | Server-side Stripe access |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Frontend Stripe integration |
STRIPE_WEBHOOK_SECRET | Webhook validation |
STRIPE_PRODUCT_PRO | Stripe Product ID |
STRIPE_PRICE_PRO_MONTHLY | Stripe Price ID |
Important rulesLink to section
- test and live modes are separate
- products and prices must match the same Stripe mode
- webhook validation is required
- production webhooks must use HTTPS
stripe listen --forward-to localhost:3000/api/webhooks/stripeBilling principle
Billing reliability depends more on correct Stripe configuration than on frontend implementation.
Seed variablesLink to section
Starter Pro includes local development fixtures.
SEED_AUTH_FIXTURES=true
SEED_DEV_USER=falseThese variables allow:
- local auth testing
- subscription testing
- protected route validation
- billing-aware product flows
Recommended production setupLink to section
Local environment
- test Stripe mode
- local database
- seed fixtures
Production environment
- live Stripe keys
- managed database
- HTTPS domains
Example environment fileLink to section
# -----------------------------------------------------------------------------
# Database
# -----------------------------------------------------------------------------
DATABASE_URL=
# -----------------------------------------------------------------------------
# App
# -----------------------------------------------------------------------------
NEXT_PUBLIC_APP_URL=
APP_BASE_URL=
# -----------------------------------------------------------------------------
# Auth
# -----------------------------------------------------------------------------
AUTH_SECRET=
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=
AUTH_TRUST_HOST=true
# -----------------------------------------------------------------------------
# Email
# -----------------------------------------------------------------------------
AUTH_RESEND_API_KEY=
AUTH_EMAIL_FROM=
# -----------------------------------------------------------------------------
# Stripe
# -----------------------------------------------------------------------------
STRIPE_SECRET_KEY=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_WEBHOOK_SECRET=
STRIPE_PRODUCT_PRO=
STRIPE_PRICE_PRO_MONTHLY=###Common mistakes
Avoid these deployment mistakes:
- exposing secret variables publicly
- mixing Stripe test and live IDs
- forgetting webhook configuration
- committing
.env.local - using weak auth secrets
- sharing production credentials
Security rule
Environment variables are part of your infrastructure security model, not only application configuration.
Recommended workflowLink to section
- configure local variables
- validate auth flows
- validate Stripe test mode
- validate webhook synchronization
- configure production secrets
- deploy staging
- validate production billing
- launch publicly
Mental modelLink to section
Public variables power the frontend.
Server variables power the business layer.