Skip to main content

Configuration

PrismConfig loads settings from environment variables and .env files with type-safe accessors. No YAML, no TOML — just key-value pairs with built-in support for environment-specific overrides.

Loading Configuration

Load from .env
From Environment Only

.env File Format

.env
.env.production
Environment variables take priority over .env file values. This lets you override settings per-deployment without changing files. The .env.{environment} file loads after .env, letting you layer environment-specific values.

Type-Safe Accessors

Reading Values

Built-In Properties

Convenience Properties

Practical Example

Configure Server from .env

Error Handling

Handle Missing Config
Keep your .env file out of version control (add it to .gitignore). Commit a .env.example with placeholder values so new developers know which keys to set.
Never put secrets directly in code. Always load them from environment variables or .env files. In production, use your platform’s secret management (Docker secrets, Kubernetes ConfigMap, etc.) to inject environment variables.