envguardv1.0.0
Type-Safe Environment Variables

Secure Your Environment Variables with Zod

EnvGuard ensures your environment variables exist and match your Zod schema, providing type safety and runtime validation for your Node.js applications.

Quick Installation

Get started with envguard in seconds

Terminal
npm install @flyinghawk/envguard zod

Why EnvGuard?

Stop worrying about missing or invalid environment variables in production

Runtime Validation
Validate environment variables at runtime using your Zod schema

Catch configuration errors early and prevent silent failures in production.

Type Safety
Get full TypeScript support with inferred types from your schema

Enjoy autocomplete and type checking for all your environment variables.

Zero Config
Simple API that works with your existing Zod schemas

No complex setup required. Define your schema and you're ready to go.

Simple to Use

Define your schema and let EnvGuard handle the rest

config.ts
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)

Want to Help Improve EnvGuard?

We're looking for contributors to help maintain and refactor the project. If you’re interested in open-source, we’d love your help!