Skip to main content
Before importing sonamu.config.ts, Sonamu reads dotenv files from the API package root. Put shared defaults in .env, environment-specific values in .env.<environment>, and machine-local overrides in .env.local.
Never commit secret .env files. Commit only examples or templates that do not contain real credentials.

Loading Order

For the active NODE_ENV, Sonamu applies sources in this order:
  1. .env
  2. .env.${NODE_ENV}
  3. .env.local
  4. Exported process environment variables
Each source can override values loaded before it. If NODE_ENV is not set, Sonamu uses development. Allowed values are test, development, staging, and production.

File Layout

The common .env file is optional when the current environment has its own file. One of .env or .env.${NODE_ENV} must exist.

Common Values

.env

Environment Values

.env.development

sonamu.config.ts

sonamu.config.ts can read process.env directly. Sonamu loads the current environment before it imports the config file.
sonamu.config.ts
Do not use the removed database.name or database.environments fields. Database names and environment-specific connections now come from SONAMU_DB_* variables and projectName.

Conversion Tips

  • Replace DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, and DATABASE_NAME with SONAMU_DB_HOST, SONAMU_DB_PORT, SONAMU_DB_USER, SONAMU_DB_PASSWORD, and SONAMU_DB_NAME.
  • Use SONAMU_DB_READONLY_* for read-only replicas. Any missing read-only field uses the current environment’s main DB value.
  • Use SONAMU_DB_FIXTURE_* only for the test fixture database.
  • Use .env.local for machine-local overrides that should apply after the shared and environment-specific files.