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.
Loading Order
For the activeNODE_ENV, Sonamu applies sources in this order:
.env.env.${NODE_ENV}.env.local- Exported process environment variables
NODE_ENV is not set, Sonamu uses
development. Allowed values are test, development, staging, and production.
File Layout
.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
- Development
- Staging
- Production
- Test
.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
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, andDATABASE_NAMEwithSONAMU_DB_HOST,SONAMU_DB_PORT,SONAMU_DB_USER,SONAMU_DB_PASSWORD, andSONAMU_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.localfor machine-local overrides that should apply after the shared and environment-specific files.