Environment Variables

Learn how to configure the environment variables.

We use one global .env file for all applications in the workspace, located in the root of the project.

Default Variables

.env.example
# ------------------------------------------------------------------------------
# ENVIRONMENT
# ------------------------------------------------------------------------------

NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_DASHBOARD_URL=http://localhost:3000
NEXT_PUBLIC_MARKETING_URL=http://localhost:3001

# ------------------------------------------------------------------------------
# Database
# ------------------------------------------------------------------------------

DATABASE_URL=mongodb://localhost:27017/aiboilerplate

# ------------------------------------------------------------------------------
# Authentication
# ------------------------------------------------------------------------------

BETTER_AUTH_URL=http://localhost:3000
BETTER_AUTH_SECRET=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

# ------------------------------------------------------------------------------
# Payments
# ------------------------------------------------------------------------------

STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=

# ------------------------------------------------------------------------------
# Email
# ------------------------------------------------------------------------------

RESEND_API_KEY=
# In production, use your own domain!
RESEND_FROM_EMAIL=onboarding@resend.dev

Only NEXT_PUBLIC_APP_ENV, NEXT_PUBLIC_DASHBOARD_URL, and NEXT_PUBLIC_MARKETING_URL may use the NEXT_PUBLIC_ prefix.

Never prefix secrets with NEXT_PUBLIC_.

Adding New Environment Variables

Add the variable to the .env file

Add a new key-value pair in the .env file, located in the root of the project.

If it's a public variable used in client-side code, prefix it with NEXT_PUBLIC_.

.env.example
NEW_ENV_VARIABLE=your-new-variable

Update turbo.json

Add the new variable to the globalEnv array in turbo.json:

turbo.json
{
  "globalEnv": ["NEW_ENV_VARIABLE"]
}

Access the variable

You can now access it using process.env.NEW_ENV_VARIABLE.