Environment Variables Configuration

Configure required environment variables for the Next.js Drizzle SaaS Kit including database, authentication, and email settings.

The SaaS Kit uses environment variables to configure various aspects of the application. This guide explains which variables are required, optional, and how to set them up for local development.

Environment File Structure

The kit uses multiple environment files:

apps/web/
├── .env # Shared, public variables (committed to git)
├── .env.development # Development-specific variables
├── .env.local # Local secrets (NEVER commit - git-ignored)

Loading order:

  1. .env - Base configuration (loaded first)
  2. .env.development - Development-specific overrides
  3. .env.local - Local overrides and secrets (highest priority, git-ignored)

Base Environment Variables

The file apps/web/.env is a shared environment file that contains all the base environment variables required for running the application. It is committed to git and is therefore public.

This file should not contain any sensitive information - please make sure to add any sensitive information to the .env.local file.

Development Environment Variables

The file apps/web/.env.development contains all the variables required for running the development environment locally.

If you add secret information to this file, please make sure it's only testing information - you don't want to commit any sensitive information to this file.

Local Environment Variables

The file apps/web/.env.local is never committed to git and can be used to store any sensitive information that you don't want to commit to the repository for making the variables available only to your local environment.

Where to store sensitive information?

While developing your application, you can store sensitive information in the .env.local file. When you deploy your application to production, you should use your hosting platform's environment variables to store sensitive information.


Next: Running the Project →