A zero-config, framework-agnostic NPM package and UI for validating and documenting your environment variables, straight from your .env.example
file.
npm install @arshtiwari/envguard
require('envguard'); // Validates env vars on startup
npx envguard validate
- Zero-config - Works with existing
.env.example
- Framework-agnostic - Node.js, Next.js, React, Vue, etc.
- Auto-documentation - Keep
.env.example
always updated - Interactive UI - Visual debugger for environment variables
- Validation - Catch missing/invalid vars before runtime
- Multiple Integration Methods - CLI, programmatic, and React UI
--
Category | Technologies |
---|---|
Backend/Core | TypeScript, Node.js |
Schema Validation | Zod, Custom Schema Generator |
File Parsing | dotenv, fs-extra |
CLI | yargs, commander |
Frontend (UI) | React.js, Vite , TailwindCSS |
Testing | Jest |
CI/CD | GitHub Actions |
npm install --save-dev @arshtiwari/envguard
# or
yarn add -D @arshtiwari/envguard
# or
pnpm add -D @arshtiwari/envguard
npx envguard validate
const { runEnvguard } = require('envguard');
if (!runEnvguard()) {
process.exit(1);
}
cd ui
npm install
npm run dev
Visit http://localhost:5173 to view the UI.
envguard/
βββ .env.example # Example env file for validation
βββ .gitignore
βββ README.md # Project documentation
βββ package.json
βββ babel.config.js # Babel config for transpiling (if needed)
βββ jest.config.js # Jest config for tests
βββ tsconfig.json # TypeScript config (optional)
βββ LICENSE
βββ dist/ # Transpiled output for npm (ignored in VCS)
β βββ ... # Compiled JS files
βββ src/ # Main source code
β βββ index.js # Main entry point (exports runEnvguard)
β βββ parser/
β β βββ envExampleParser.js
β βββ schema/
β β βββ schemaGenerator.js
β βββ validator/
β β βββ validator.js
β βββ reporter/
β β βββ errorReporter.js
β βββ cli/
β β βββ cli.js # CLI entry point
β βββ utils/
β β βββ helpers.js
β βββ types/
β βββ index.d.ts # Type definitions
βββ server/ # Backend server for live UI (optional)
β βββ server.js
βββ scripts/ # Utility scripts (e.g., generate .env.example)
β βββ generateEnvExample.js
βββ tests/ # Jest test files
β βββ parser.test.js
β βββ schema.test.js
β βββ validator.test.js
β βββ cli.test.js
βββ ui/ # React UI dashboard (dev/optional)
β βββ src/
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css
β β βββ components/
β β βββ EnvTable.jsx
β βββ public/
β β βββ index.html
β β βββ env-vars.json # (for demo, replaced by API in prod)
β βββ tailwind.config.js
β βββ vite.config.js
βββ website/ # Landing page (for npm promotion)
β βββ src/
β β βββ App.jsx
β β βββ main.jsx
β β βββ components/
β β βββ Hero.jsx
β β βββ Pricing.jsx
β βββ public/
β β βββ index.html
β βββ tailwind.config.js
β βββ vite.config.js
- Parse your
.env.example
for variable names and defaults. - Generate a validation schema automatically.
- Validate your actual environment (
process.env
) against the schema. - Report errors in CLI, programmatically, or visually in the UI.
project-root/
βββ .env # Local environment (gitignored)
βββ .env.example # Template with all required vars
βββ .env.development # Environment-specific vars
βββ .env.production
βββ package.json
# Required variables
API_KEY=your_api_key_here
DATABASE_URL=postgres://user:pass@localhost:5432/db
# Optional variables
# PORT=3000
# DEBUG=false
module.exports = {
// Custom schema rules
rules: {
API_KEY: {
minLength: 32,
pattern: /^sk_[a-zA-Z0-9]+$/
}
},
// Additional environments
environments: ['staging', 'test'],
// Custom error messages
messages: {
missing: 'π¨ Missing required env var: {var}',
invalid: 'β Invalid value for {var}: {error}'
}
};
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
MIT Β© Arsh Tiwari
Have questions or need help? Feel free to reach out!
- Email: arshtiwari12345@gmail.com
- GitHub: @ArshTiwari2004
- Twitter/X: @ArshTiwari17
- LinkedIn: Arsh Tiwari
For bug reports or feature requests, please open an issue on GitHub.
Happy coding! May your environment variables always be valid. β¨