You're reading docs for Nextly Alpha. APIs may change between releases.

Configuration

Environment Variables

All environment variables used by Nextly, organized by category with required vs optional indicators.

Nextly uses environment variables for database connections, authentication, storage, and other runtime settings. Copy .env.example to .env and configure the values for your environment.

cp .env.example .env

Database (Required)

VariableRequiredDefaultDescription
DB_DIALECTYespostgresqlDatabase dialect: postgresql, mysql, or sqlite.
DATABASE_URLYes--Full database connection string.
DB_POOL_MAXNo20Maximum connections in the pool.
DB_POOL_MINNo2Minimum connections in the pool.
DB_CONNECTION_TIMEOUTNo30000Connection timeout in milliseconds.
DB_QUERY_TIMEOUTNo15000Query timeout in milliseconds.
DB_HEALTHCHECK_INTERVAL_MSNo30000Health check interval in milliseconds.
DB_SNAKE_CASENofalseUse snake_case for database column names instead of camelCase.
DB_LOG_ENABLEDNofalseEnable database query logging.
DB_LOG_LEVELNo--Log level for database queries (e.g., debug).

Connection string formats:

# PostgreSQL (recommended for production)
DATABASE_URL=postgresql://user:password@localhost:5432/nextly_dev

# MySQL
DATABASE_URL=mysql://root:root@localhost:3306/nextly_dev

# SQLite (development only)
DATABASE_URL=file:./dev.db

Authentication (Required)

Nextly uses Auth.js v5 for authentication. These variables are required for auth to function.

VariableRequiredDefaultDescription
AUTH_SECRETYes--Secret key for encrypting JWTs and session tokens. Minimum 32 characters. Generate with openssl rand -base64 32.
AUTH_TRUST_HOSTNotrueTrust the host header. Recommended true for Next.js deployments.
NEXTAUTH_URLYes--Public URL where the app is accessible. Required for OAuth callbacks.
NEXTAUTH_URL_INTERNALNoSame as NEXTAUTH_URLInternal URL for server-side API calls.

OAuth Providers (Optional)

Configure these only if you use social login.

VariableDescription
AUTH_GOOGLE_IDGoogle OAuth client ID.
AUTH_GOOGLE_SECRETGoogle OAuth client secret.
AUTH_GITHUB_IDGitHub OAuth client ID.
AUTH_GITHUB_SECRETGitHub OAuth client secret.

Application URLs

VariableRequiredDefaultDescription
NEXT_PUBLIC_APP_URLNohttp://localhost:3000Public-facing app URL. Used in client-side code.
API_BASE_URLNohttp://localhost:3000/apiBase URL for API routes.

Storage (Required)

Nextly requires a cloud storage adapter for media uploads. Choose one backend.

VariableRequiredDefaultDescription
STORAGE_ADAPTERYesvercelStorage backend: vercel or s3.

Vercel Blob

Recommended for Vercel deployments.

VariableRequiredDescription
BLOB_READ_WRITE_TOKENYes (if vercel)Vercel Blob storage token from your Vercel dashboard.

S3 / S3-Compatible

Works with AWS S3, Cloudflare R2, MinIO, and DigitalOcean Spaces.

VariableRequiredDescription
S3_BUCKETYes (if s3)S3 bucket name.
S3_REGIONYes (if s3)AWS region (e.g., us-east-1). Use auto for R2.
AWS_ACCESS_KEY_IDYes (if s3)Access key ID.
AWS_SECRET_ACCESS_KEYYes (if s3)Secret access key.
S3_ENDPOINTNoCustom endpoint URL. Required for R2 and MinIO.
S3_PUBLIC_URLNoPublic URL prefix for R2 (e.g., https://pub-xxxx.r2.dev).
S3_FORCE_PATH_STYLENoSet true for MinIO.

Email / SMTP (Optional)

Required only for sending emails (password resets, notifications). If any SMTP variable is set in production, all must be configured.

VariableRequiredDefaultDescription
SMTP_HOSTNo--SMTP server hostname (e.g., smtp.gmail.com).
SMTP_PORTNo587SMTP port. 587 for TLS, 465 for SSL.
SMTP_USERNo--SMTP authentication username.
SMTP_PASSNo--SMTP authentication password.
SMTP_FROMNo--From address for outgoing emails.

Permission Caching (Optional)

Nextly includes a hybrid permission cache (in-memory + database) that reduces permission check queries by approximately 60%.

VariableRequiredDefaultDescription
PERMISSION_CACHE_ENABLEDNotrueEnable hybrid permission caching.
PERMISSION_CACHE_TTL_SECONDSNo86400Time-to-live for database cache entries (seconds).
PERMISSION_CACHE_MEMORY_SIZENo10000In-memory LRU cache size (number of entries).
DEBUG_CACHENo--Set 1 to enable cache debugging logs.

The database permission cache requires periodic cleanup. Set up a daily cron job:

0 2 * * * curl -X POST http://localhost:3000/api/auth/cache/cleanup

Debug and Feature Flags (Optional)

VariableRequiredDefaultDescription
NODE_ENVNodevelopmentRuntime environment: development, production, or test.
DEBUG_RBACNo--Set 1 to enable detailed RBAC permission logs.

Docker Development (Optional)

Used by docker-compose.yml for local database setup. Not needed when connecting to an existing database.

VariableDefaultDescription
DB_NAMEnextly_devPostgreSQL database name.
DB_USERpostgresPostgreSQL user.
DB_PASSWORD--PostgreSQL password. Change in production.
DB_PORT5432PostgreSQL port.
ADMINER_PORT8080Adminer UI port (database browser).
REDIS_PORT6379Redis cache port.
DRIZZLE_STUDIO_PORT4983Drizzle Studio port for database GUI.

Example .env

A minimal production .env file:

# Database
DB_DIALECT=postgresql
DATABASE_URL=postgresql://user:password@db.example.com:5432/nextly_prod

# Auth
AUTH_SECRET=your-generated-secret-at-least-32-characters-long
NEXTAUTH_URL=https://your-domain.com
NEXT_PUBLIC_APP_URL=https://your-domain.com

# Storage (Vercel Blob)
STORAGE_ADAPTER=vercel
BLOB_READ_WRITE_TOKEN=vercel_blob_rw_xxxxxxxxxxxx

A development .env file with S3-compatible storage (MinIO):

# Database
DB_DIALECT=postgresql
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/nextly_dev

# Auth
AUTH_SECRET=dev-secret-minimum-32-characters-long-replace-in-production
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Storage (MinIO)
STORAGE_ADAPTER=s3
S3_BUCKET=nextly-dev
S3_REGION=us-east-1
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
S3_ENDPOINT=http://localhost:9000
S3_FORCE_PATH_STYLE=true

Next Steps

  • Nextly Config -- the central nextly.config.ts file
  • Database -- choose and configure PostgreSQL, MySQL, or SQLite
  • Deployment -- production environment variable checklist
  • Authentication -- auth-related environment variables in depth