ultraenv: Type-Safe Environment Variables for TypeScript (Validated at Startup)
How many times have you deployed to production only to get a runtime crash because process.env.DATABASE_URL was undefined? ultraenv eliminates that entire class of bug. What is ultraenv? A TypeScri...

Source: DEV Community
How many times have you deployed to production only to get a runtime crash because process.env.DATABASE_URL was undefined? ultraenv eliminates that entire class of bug. What is ultraenv? A TypeScript-first environment variable manager that validates all your env vars at application startup. npm install ultraenv bun add ultraenv The Problem // Without ultraenv - crashes at runtime in production! const db = new Database(process.env.DATABASE_URL); // Could be undefined! The Solution import { defineEnv } from 'ultraenv'; const env = defineEnv({ DATABASE_URL: { type: 'string', required: true }, PORT: { type: 'number', default: 3000 }, NODE_ENV: { type: 'enum', values: ['development', 'production', 'test'] }, API_SECRET: { type: 'string', required: true, secret: true } }); // All vars are fully typed and guaranteed! const db = new Database(env.DATABASE_URL); // string! const port = env.PORT; // number! Features Startup validation with clear error messages Automatic type coercion (string to n