Quickstart guide
Current requirements
DMNO Config requires either of the following:
node(>22.x) + eitherpnpm,npm, oryarnbun
-
Setup
dmnoin your projectRun this command in the root of your project:
Terminal window npx dmno initTerminal window pnpm dlx dmno initTerminal window yarn dlx dmno initTerminal window bunx dmno initThis will create a
.dmnofolder in the root of your project with aconfig.mtsfile, including config items in yourschemathat we automatically scaffold using config items we find in.envfiles and in your source code. If in a monorepo, any additional services of your choice will get their own.dmnofolders and associated files. Each.dmnofolder looks something like this:Directory/your-project
Directory.dmno
Directory.typegen/ (generated types)
- …
- .env.local (optional local overrides file, gitignored)
- config.mts (your config schema)
- tsconfig.json (dmno specific tsconfig)
- … the rest of your files and folders
-
Run
dmno resolvein watch modeThis will give you instant feedback while you author your config schema.
Terminal window npm exec -- dmno resolve -wTerminal window pnpm exec dmno resolve -wTerminal window yarn exec -- dmno resolve -wTerminal window bun run dmno resolve -w -
Write your schema
The config schema and other settings live in the
.dmno/config.mtsfiles.dmno initdoes its best to scaffold out the initial version of this schema but it should be reviewed. Updating each item with a description,required, andsensitiveis a great next step. You can then improve your schema over time, adding validations, and setting values from within the schema itself.Your initial schema should look something like this:
.dmno/config.mts import { DmnoBaseTypes, defineDmnoService } from 'dmno';export default defineDmnoService({schema: {PUBLIC_API_BASE_URL: {extends: DmnoBaseTypes.url,description: 'Base URL for the public API',},PUBLIC_GOOGLE_ANALYTICS_ID: {description: 'Google Analytics ID',},DATABASE_URL: {sensitive: true,extends: DmnoBaseTypes.url,description: 'Database connection string',},SECRET_API_KEY: {sensitive: true,},JWT_SECRET: {sensitive: true,},},});Check out the schema guide for full details.
And if you would like more information on how we use
.envfiles check out `.env’ file guide -
Configure framework specific integrations
We provide drop-in integrations for many popular frameworks, and more are in the works.
dmno initis smart enough to install the relevant integrations for each service. You can also read more about each integration on their respective pages and update them as needed.In this case of Astro or Vite, the integrations should work out of the box. In other cases, like Node.js or Next.js, you will need to update your
package.jsonscripts to usedmno runso that your resolved config is passed to the script in question. -
Use
DMNO_CONFIGto access your configWe recommend migrating to
DMNO_CONFIGas it provides helpful improvements like TypeScript autocompletion and IntelliSense.For example:
// 😿 still works, but no type-safety, and will be a stringif (!process.env.SOME_NUMBER) {throw new Error('Missing SOME_NUMBER env var');}const myConfigNum = parseFloat(process.env.SOME_NUMBER);// 🎉 easier, safer, full type-safetyconst myConfigNum = DMNO_CONFIG.SOME_NUMBER;const IS_PROD = DMNO_CONFIG.NODE_ENV === 'production';You could continue to use
process.env/import.meta.envto access your config and still benefit from DMNO’s validation logic. But,DMNO_CONFIGgives you the full benefits of DMNO.