Secure secret injection for any language — encrypted .env files + 1Password, zero secrets on disk.
envlock combines dotenvx encrypted .env files with 1Password CLI to inject secrets into any process at runtime. Nothing is ever written to the filesystem in plaintext.
How it works:
AI coding tools like Copilot and Cursor have broad filesystem access by default. Malicious npm packages exploit this too — supply chain attacks increasingly target local credential files. If your secrets live in a plain .env file, they're one compromised dependency or one AI prompt away from being exfiltrated.
Plain .env files also get committed accidentally, shared over Slack, and copied onto every developer's laptop with no audit trail.
envlock removes the file entirely. Secrets only exist in memory, for the lifetime of the process that needs them.
| Directory | What it is |
|---|---|
apps/website/ |
Static showcase site (Vite + React) |
examples/ |
Fully runnable minimal examples per language |
Each example is a self-contained minimal app showing how to use envlock with a specific language or framework.
| Example | Language / Framework |
|---|---|
examples/nextjs/ |
Next.js (envlock-next) |
examples/node/ |
Node.js (Express) |
examples/python/ |
Python (Flask) |
examples/go/ |
Go (net/http) |
examples/rust/ |
Rust (Axum) |
examples/ruby/ |
Ruby (Sinatra) |
examples/java/ |
Java (Spring Boot) |
examples/php/ |
PHP |
examples/dotnet/ |
.NET (ASP.NET Core) |
examples/hardhat/ |
Hardhat (Ethereum) |
Every example follows the same pattern — see any examples/<lang>/README.md for setup steps.
All examples require:
- Node.js 18+
- 1Password CLI — for storing decryption keys (
brew install --cask 1password-cli@beta) - 1Password desktop app — with CLI integration enabled (Settings → Developer → Integrate with 1Password CLI)
op signinWith biometric unlock enabled, the CLI authenticates automatically. You can adjust the auto-lock interval so you only need to unlock once per day.
For Next.js, use envlock-next — a native plugin that integrates directly with next.config.ts:
pnpm add envlock-nextThe postinstall script automatically rewrites your package.json scripts:
{
"scripts": {
"dev": "envlock dev",
"build": "envlock build",
"start": "envlock start"
}
}Then wrap your config:
// next.config.ts
import { withEnvlock } from "envlock-next";
export default withEnvlock(
{},
{
onePasswordEnvId: "your-1password-environment-id",
},
);See examples/nextjs/ for a full working example.
Vercel's build environment doesn't have 1Password CLI, so envlock falls back to its CI mode — you provide the decryption key directly as an environment variable and it skips 1Password automatically.
npx @dotenvx/dotenvx set API_SECRET "my-secret" -f .env.productionCommit .env.production (encrypted values are safe to commit). Never commit .env.keys.
In your Vercel project go to Settings → Environment Variables and add:
| Name | Value | Environment |
|---|---|---|
DOTENV_PRIVATE_KEY_PRODUCTION |
(value from .env.keys) |
Production |
Push your code. During the Vercel build, envlock detects DOTENV_PRIVATE_KEY_PRODUCTION is already set and decrypts .env.production without calling 1Password.
⟐ injecting env (4) from .env.production · [email protected]
▲ Next.js x.x.x
The encrypted
.env.productionfile is safe to commit — without the private key it is unreadable.
- No plaintext secrets on disk — encrypted values are safe to commit
- No
.env.keysfile — decryption keys live in 1Password only - In-memory decryption — secrets are never written to the filesystem
- Works with any runtime — Node, Python, Go, Rust, Ruby, Java, PHP, .NET, and more
- CI-friendly — set
DOTENV_PRIVATE_KEY_*directly and envlock skips 1Password automatically

