Getting Started
-
Install the dependencies
-
Define your files
Directoryapp
Directoryconfig
- base.json
Directorysrc
- …
Directoryconfig
- index.ts
-
Use your type-safe config
Now, you can access the configuration anywhere in your server-side code:
Next steps
Section titled “Next steps”That is a single layer. The point of Layerfig is stacking several:
- Add a per-environment file on top of
base.json. - Override values at runtime with environment variables.
- Reference environment variables from inside your config files with slots.
Compatibility
Section titled “Compatibility”| Requirement | Detail |
|---|---|
| Zod | v4 — bundled, and re-exported as z |
| Parser packages | @layerfig/parser-* v6 pairs with @layerfig/config v3 |
| Module formats | ESM and CommonJS on the server; ESM only for /client |
| Runtime | Any runtime with node:fs and node:path — see Deno |