Skip to content

Environment Variables

This page lists every environment variable that Velox TS reads, organized by package. Most are optional since environment-aware presets provide sensible defaults — you typically only need to set secrets and service URLs.

VariableDescriptionExample
NODE_ENVEnvironment modedevelopment, test, production
DATABASE_URLDatabase connection stringfile:./dev.db or postgresql://...
VariableDescriptionMinimum
JWT_SECRETAccess token signing key32 characters
JWT_REFRESH_SECRETRefresh token signing key32 characters
SESSION_SECRETSession signing key (if using sessions)32 characters

These are required when using usePresets() in production:

VariableDescriptionUsed By
REDIS_URLRedis connection URLCache, Queue, Events
RESEND_API_KEYResend API keyMail
S3_BUCKETS3 bucket nameStorage
VariableDescriptionDefault
PORTServer port3030 (prod reads from env)
LOG_LEVELLogging verbositydebug (dev), warn (prod)
VariableDescriptionDefault
AWS_REGIONAWS regionus-east-1
AWS_ACCESS_KEY_IDAWS access key-
AWS_SECRET_ACCESS_KEYAWS secret key-

When using SMTP driver instead of Resend:

VariableDescriptionDefault
SMTP_HOSTSMTP server host-
SMTP_PORTSMTP server port587
SMTP_USERSMTP username-
SMTP_PASSSMTP password-
.env
NODE_ENV=development
# Database (SQLite for dev)
DATABASE_URL=file:./dev.db
# Auth (use secure values in production!)
JWT_SECRET=dev-jwt-secret-min-32-characters-long
JWT_REFRESH_SECRET=dev-refresh-secret-min-32-chars-here
# Optional: Override log level
LOG_LEVEL=debug
.env.production
NODE_ENV=production
# Database (PostgreSQL)
DATABASE_URL=postgresql://user:password@host:5432/myapp?sslmode=require
# Auth (generate with: openssl rand -base64 48)
JWT_SECRET=<secure-random-secret-min-32-chars>
JWT_REFRESH_SECRET=<secure-random-secret-min-32-chars>
SESSION_SECRET=<secure-random-secret-min-32-chars>
# Redis (for cache, queue, events)
REDIS_URL=redis://user:password@host:6379
# Mail (Resend)
RESEND_API_KEY=re_xxxxxxxxxxxxx
# Storage (S3)
S3_BUCKET=your-bucket
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
# Optional: Override defaults
PORT=8080
LOG_LEVEL=info
Terminal window
# Generate a secure random secret (Node.js)
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
# Generate using OpenSSL
openssl rand -base64 32

Velox TS uses dotenv for environment variable loading:

// Automatic loading in entry point
import 'dotenv/config';
// Or manual loading
import dotenv from 'dotenv';
dotenv.config({ path: '.env.production' });

For RSC apps with Vite, load dotenv explicitly:

import dotenv from 'dotenv';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
dotenv.config({ path: resolve(__dirname, '..', '.env') });

Velox TS provides built-in validation for production deployments:

import { validateSecurityOrThrow } from '@veloxts/velox';
// Validates in production, silent in dev/test
validateSecurityOrThrow();
// Or validate auth secrets specifically
import { validateAuthSecrets } from '@veloxts/velox';
validateAuthSecrets();

This validates:

  • Required environment variables are set (DATABASE_URL)
  • JWT secrets meet minimum length (32 characters)
  • Secrets are not weak patterns (e.g., “password”, “secret”)

See Security Validation for details.

For additional validation:

import { z } from 'zod';
const envSchema = z.object({
NODE_ENV: z.enum(['development', 'production', 'test']),
DATABASE_URL: z.string().min(1),
JWT_SECRET: z.string().min(32),
JWT_REFRESH_SECRET: z.string().min(32),
});
const env = envSchema.parse(process.env);