v2.1.7 is now available

Type-Safe Environment Config for Node.js

Simplify .env management with Zod-powered validation. Catch errors early, boost developer confidence, and ship Node.js apps faster.

npm install nviron
Type Safety
Full TypeScript support with automatic type inference from your Zod schemas.
Runtime Validation
Validate environment variables at runtime to catch misconfigurations early.
Developer Experience
Clear error messages and autocomplete support in your IDE.
Hot Reloading
Automatically reload configuration when environment files change during development.
Secrets Management
Securely handle sensitive information with built-in best practices.
CLI Integration
Seamlessly integrate with your existing CLI workflows and scripts.

Zero config.
Maximum safety.

Define your environment schema with Zod and get immediate type safety and runtime validation. No more debugging missing environment variables in production.

env.ts
import { defineEnv, z } from "nviron";

const env = defineEnv({
 PORT: z.coerce.number().default(3000),
 DATABASE_URL: z.string().url(),
 NODE_ENV: z.enum(["development", "production"]),
});

// usage
console.log(env.PORT); // Typed & Validated!