Skip to main content

Environment Variables

Complete reference for all Lektr environment variables.

Database

VariableRequiredDefaultDescription
DATABASE_URLNo-Full PostgreSQL connection string
POSTGRES_USERNolektrDatabase username
POSTGRES_PASSWORDNolektr_devDatabase password
POSTGRES_DBNolektrDatabase name
POSTGRES_HOSTNodbDatabase hostname (use db for Docker)
POSTGRES_PORTNo5432Database port

_Either DATABASE_URL or the individual POSTGRES\__ variables are required.

Authentication

VariableRequiredDefaultDescription
JWT_SECRETProd onlyAuto-generatedSecret key for JWT tokens
ADMIN_EMAILNoadmin@lektr.localInitial admin email
ADMIN_PASSWORDNoadmin123Initial admin password
caution

Always set JWT_SECRET in production! Using auto-generated secrets will invalidate sessions on restart.

Email (SMTP)

VariableRequiredDefaultDescription
SMTP_HOSTNo-SMTP server hostname
SMTP_PORTNo587SMTP server port
SMTP_USERNo-SMTP authentication username
SMTP_PASSNo-SMTP authentication password
SMTP_SECURENofalseUse SSL/TLS (for port 465)
MAIL_FROM_NAMENoLektrSender display name
MAIL_FROM_EMAILNo-Sender email address

Application

VariableRequiredDefaultDescription
APP_URLNohttp://localhost:3002Base URL for email links
CORS_ORIGINSNo*Allowed CORS origins (comma-separated)
NODE_ENVNodevelopmentEnvironment mode

Features

VariableRequiredDefaultDescription
HARDCOVER_API_KEYNo-API key for book metadata enrichment
info

DIGEST_CRON has been removed. Digest scheduling is now per-user and timezone-aware — each user configures their preferred delivery time.

Docker

VariableRequiredDefaultDescription
LEKTR_PORTNo80Host port for Nginx proxy

Example .env File

# Database (defaults work out of the box)
POSTGRES_USER=lektr
POSTGRES_PASSWORD=secure-password-here
POSTGRES_DB=lektr
POSTGRES_HOST=db
POSTGRES_PORT=5432

# Security
JWT_SECRET=your-very-long-secret-key-at-least-32-chars

# Admin
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=change-me-immediately

# Email
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your@gmail.com
SMTP_PASS=your-app-password
MAIL_FROM_NAME=Lektr
MAIL_FROM_EMAIL=noreply@example.com

# Application
APP_URL=https://lektr.example.com
HARDCOVER_API_KEY=your-hardcover-key

# Docker
LEKTR_PORT=80