secret-env
v1.0.2
Published
A secure alternative to dotenv — prevents sensitive '.env.secret' files from being pushed to Git and creates '.env.secret.example' automatically. Supports CommonJS and ES Module.
Maintainers
Readme
secret-env 🔒
A secure alternative to dotenv — prevents sensitive .env.secret files from being pushed to Git and creates .env.secret.example automatically. Supports CommonJS and ES Module.
Requires Node.js v14+
🚀 Install
npm install secret-env⚙️ Usage
Create .env.secret file at the project root
PORT=8080
DB_USER=root
DB_PASS=12345
SECRET_KEY=mysecretCommonJS
const secretEnv = require("secret-env");
secretEnv.config();or
require("secret-env").config();ES Module
import { config } from "secret-env";
config();Access anywhere in your app
console.log(secretenv.PORT); // output: 8080
console.log(secretenv.DB_USER); // output: root
### Features
- Loads `.secret-env`
- Adds `.env.secret` to `.gitignore`
- Creates `.env.secret.example` with dummy values (`your_` prefix)
- Prevents your secrets from leaking