Getting Started

Environment Variables

Complete reference for all configuration options

Environment Variables

TL;DR: Copy .env.example to .env.local, set the 3 required variables, done.

Quick Setup

cp .env.example .env.local

Minimum required:

DATABASE_URL="postgresql://postgres:postgres@localhost:5432/straktur"
BETTER_AUTH_SECRET="your-32-char-secret-here"
NEXT_PUBLIC_APP_URL="http://localhost:3000"

Complete Reference

Core (Required)

VariableTypeRequiredDescription
DATABASE_URLstringYesPostgreSQL connection URL
BETTER_AUTH_SECRETstringYesAuth secret (min 32 chars)
NEXT_PUBLIC_APP_URLstringYesApp URL for redirects
NODE_ENVenumNodevelopment | test | production

Seed Data (Development)

VariableTypeRequiredDefaultDescription
ALLOW_DB_SEEDbooleanNofalseEnable db:seed command
ALLOW_DB_RESETbooleanNofalseEnable db:reset command
SEED_USER_EMAILstringNo[email protected]Demo user email
SEED_USER_PASSWORDstringNopassword123Demo user password
SEED_USER_NAMEstringNoAdmin UserDemo user name
SEED_ORG_NAMEstringNoAcme IncDemo organization name
SEED_ORG_SLUGstringNoacmeDemo organization slug

Email

VariableTypeRequiredDefaultDescription
EMAIL_PROVIDERenumNoconsoleconsole | smtp | resend
EMAIL_FROMstringNonoreply@localhostSender address
EMAIL_REPLY_TOstringNo-Reply-to address

SMTP options (when EMAIL_PROVIDER=smtp):

VariableTypeRequiredDescription
SMTP_HOSTstringYesSMTP server host
SMTP_PORTstringYesSMTP port (587, 465, 25)
SMTP_USERstringYesSMTP username
SMTP_PASSstringYesSMTP password
SMTP_SECUREbooleanNoUse TLS (true for 465)

Resend options (when EMAIL_PROVIDER=resend):

VariableTypeRequiredDescription
RESEND_API_KEYstringYesResend API key

File Storage

VariableTypeRequiredDefaultDescription
STORAGE_PROVIDERenumNos3s3 | supabase
STORAGE_INTENT_SECRETstringNo-Secret for signed upload URLs

S3/R2/MinIO options (when STORAGE_PROVIDER=s3):

VariableTypeRequiredDescription
S3_BUCKETstringYesBucket name
S3_REGIONstringYesRegion (e.g., us-east-1)
S3_ENDPOINTstringNoCustom endpoint (for R2/MinIO)
S3_ACCESS_KEY_IDstringYesAccess key
S3_SECRET_ACCESS_KEYstringYesSecret key

Supabase Storage options (when STORAGE_PROVIDER=supabase):

VariableTypeRequiredDescription
SUPABASE_URLstringYesSupabase project URL
SUPABASE_SERVICE_KEYstringYesService role key
SUPABASE_STORAGE_BUCKETstringYesStorage bucket name

Example Configurations

Development (minimal)

# .env.local
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/straktur"
BETTER_AUTH_SECRET="development-secret-min-32-characters-long"
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Enable seeding
ALLOW_DB_SEED="true"

Development (with email preview)

# .env.local
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/straktur"
BETTER_AUTH_SECRET="development-secret-min-32-characters-long"
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Console email (prints to terminal)
EMAIL_PROVIDER="console"

Production

# .env (production)
DATABASE_URL="postgresql://user:[email protected]:5432/straktur"
BETTER_AUTH_SECRET="<generated-secret>"
NEXT_PUBLIC_APP_URL="https://app.example.com"
NODE_ENV="production"

# Email via Resend
EMAIL_PROVIDER="resend"
EMAIL_FROM="[email protected]"
RESEND_API_KEY="re_xxx"

# Storage via S3
STORAGE_PROVIDER="s3"
S3_BUCKET="straktur-files"
S3_REGION="us-east-1"
S3_ACCESS_KEY_ID="AKIA..."
S3_SECRET_ACCESS_KEY="..."

Adding New Variables

Environment variables are validated using T3 Env.

File: src/lib/env.ts

// src/lib/env.ts
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"

export const env = createEnv({
  server: {
    // Add your server variable here
    MY_NEW_VAR: z.string().min(1),
  },
  client: {
    // Add your client variable here (must start with NEXT_PUBLIC_)
    NEXT_PUBLIC_MY_VAR: z.string().optional(),
  },
  runtimeEnv: {
    MY_NEW_VAR: process.env.MY_NEW_VAR,
    NEXT_PUBLIC_MY_VAR: process.env.NEXT_PUBLIC_MY_VAR,
  },
})

Usage:

import { env } from "@/lib/env"

// Type-safe access
const value = env.MY_NEW_VAR

Common Mistakes

Wrong: Using process.env directly

const url = process.env.DATABASE_URL // No type safety!

Correct: Using env from lib

import { env } from "@/lib/env"
const url = env.DATABASE_URL // Type-safe + validated

On this page