Reference

Environment variables

Complete reference for all environment variables read by Auth Service.

Environment variables

All variables are validated at startup using Zod. If a required variable is missing or invalid, the process exits with an error listing every failing field.

Server

VariableRequiredDefaultDescription
PORTno3001TCP port the Fastify server binds to
HOSTno0.0.0.0Bind address
NODE_ENVnodevelopmentdevelopment, production, or test. Controls log level and transport.

BetterAuth (required)

VariableRequiredDefaultDescription
BETTER_AUTH_SECRETyesRandom secret used to sign sessions (min 16 chars). Generate with openssl rand -base64 32.
BETTER_AUTH_URLyesPublic base URL of Auth Service, e.g. https://auth.example.com. Used as the OIDC issuer and in email links.

Database (required)

VariableRequiredDefaultDescription
DATABASE_URLyesPostgreSQL connection string, e.g. postgres://user:pass@host:5432/dbname
POSTGRES_USERyes (Compose)Postgres user — used by the postgres service in Compose
POSTGRES_PASSWORDyes (Compose)Postgres password
POSTGRES_DByes (Compose)Database name
POSTGRES_PORTno5433Host-side port for the Postgres container (dev only)

Bootstrap

VariableRequiredDefaultDescription
ADMIN_EMAILnoEmail address for the superadmin created at first boot
ADMIN_PASSWORDnoPassword for the superadmin (min 8 chars). If either variable is absent, bootstrap is skipped.

CORS and sessions

VariableRequiredDefaultDescription
CORS_ORIGINSnohttp://localhost:5173Comma-separated list of allowed CORS origins
SESSION_DOMAINnoWhen set, enables cross-subdomain cookies. Set to the apex domain, e.g. example.com.

Email (SMTP)

All SMTP variables are optional. When SMTP_HOST is not set, password reset and verification emails are silently skipped.

VariableRequiredDefaultDescription
SMTP_HOSTnoSMTP server hostname
SMTP_PORTno587SMTP port. Port 465 enables implicit TLS; all others use STARTTLS.
SMTP_USERnoSMTP authentication username
SMTP_PASSnoSMTP authentication password
SMTP_FROMnoauth-service <no-reply@localhost>From address for outgoing emails

Templates

VariableRequiredDefaultDescription
TEMPLATES_DIRnoAbsolute path to a directory containing custom HTML templates for /login, /register, and /verify-email. See Custom templates.

Stripe billing

VariableRequiredDefaultDescription
STRIPE_SECRET_KEYnoStripe secret API key (sk_live_… or sk_test_…). When absent, Stripe features are disabled.
STRIPE_WEBHOOK_SECRETnoStripe webhook signing secret (whsec_…). Required for the webhook endpoint to validate Stripe events.

Social login providers

Each provider requires both CLIENT_ID and CLIENT_SECRET to be set. If either is missing, the provider is disabled.

VariableRequiredDefaultDescription
GOOGLE_CLIENT_IDnoGoogle OAuth app client ID
GOOGLE_CLIENT_SECRETnoGoogle OAuth app client secret
GITHUB_CLIENT_IDnoGitHub OAuth app client ID
GITHUB_CLIENT_SECRETnoGitHub OAuth app client secret
LINKEDIN_CLIENT_IDnoLinkedIn OAuth app client ID
LINKEDIN_CLIENT_SECRETnoLinkedIn OAuth app client secret
MICROSOFT_CLIENT_IDnoMicrosoft OAuth app client ID
MICROSOFT_CLIENT_SECRETnoMicrosoft OAuth app client secret
APPLE_CLIENT_IDnoApple OAuth app client ID
APPLE_CLIENT_SECRETnoApple OAuth app client secret

Config keys for social providers are validated at startup, but the BetterAuth socialProvider() plugins are only enabled for google and github. The remaining provider keys are reserved for future use.

Copyright © 2026