Introduction
Read environment variables as typed values, with zero runtime dependencies, plus zod/valibot/arktype validation, and much more.
envapt reads environment variables as typed values. You give it a key and a fallback; it returns a number, boolean, URL, Date, an array, or any type you define, instead of the string | undefined you get from process.env.
const redisUrl = .('REDIS_URL', ., new ('redis://localhost:6379'));Two ways to read
Read values functionally with Envapter, or bind them to class fields with the @Envapt decorator. Both share the same parsing, converters, and cache.
class {
@('REDIS_URL', { : ., : new ('redis://localhost:6379') })
declare static readonly : URL;
}What you get
- Typed values. A fallback removes
undefinedfrom the return type. Converters convert numbers, booleans, bigint, JSON, URLs, dates, durations, and arrays, or pass your own function or a Standard Schema validator (zod, valibot, arktype). - Zero runtime dependencies. envapt ships its own
.envparser (used on Node, Bun, and Deno), so nothing is added to your dependency tree. - The same API on Node, Bun, and Deno, Cloudflare Workers, and the browser. Off Node you bind an environment source. See Compatibility and Sources.
.envloading built in on Node. A per-environment file cascade,${VAR}templates, and strict / required checks. The cascade needs a filesystem; off Node you pass values through the source.
Next
Start with the Quick Start, then the Envapter reader API.