Skip to content

OPBR/vite-plugin-typed-env

Repository files navigation

vite-plugin-typed-env

A Vite plugin that automatically generates TypeScript types and Zod schemas from your .env files.

Packages

Package Description
vite-plugin-typed-env Core plugin

Features

  • Auto-generated TypeScript types - env.d.ts with proper type inference
  • Zod schema generation - Runtime validation with env.schema.ts
  • Runtime loader - env.ts that validates and exposes typed environment variables
  • Vite import.meta.env augmentation - Full type support for Vite's env system
  • Hot reload - Automatically regenerate types when .env files change
  • Smart type inference - Auto-detects types from values (boolean, number, URL, arrays, etc.)
  • Annotation support - Fine-grained type control via special comments

Quick Start

npm install vite-plugin-typed-env -D
npm install zod
// vite.config.ts
import envTs from 'vite-plugin-typed-env'

export default defineConfig({
  plugins: [envTs()]
})

See packages/core/README.md for full documentation.

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Test
pnpm test

# Lint
pnpm lint

License

MIT

About

Typed environment variables for Vite with auto-generated types and runtime validation. 自动生成环境变量类型和运行时验证功能的 Vite 插件

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors