EnvGuard ensures your environment variables exist and match your Zod schema, providing type safety and runtime validation for your Node.js applications.
Get started with envguard in seconds
npm install @flyinghawk/envguard zod
Stop worrying about missing or invalid environment variables in production
Catch configuration errors early and prevent silent failures in production.
Enjoy autocomplete and type checking for all your environment variables.
No complex setup required. Define your schema and you're ready to go.
Define your schema and let EnvGuard handle the rest
import { z } from 'zod'
import { loadDotEnv } from 'envguard'
const envSchema = z.object({
DATABASE_URL: z.string().url(),
API_KEY: z.string().min(1),
PORT: z.coerce.number().default(3000),
NODE_ENV: z.enum(['development', 'production', 'test'])
})
export const env = loadDotEnv(envSchema)
console.log(env.DATABASE_URL)
console.log(env.PORT)
console.log(env.API_KEY)
We're looking for contributors to help maintain and refactor the project. If you’re interested in open-source, we’d love your help!