
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Type-safe environment variables. Loads .env files, validates with Zod/Valibot/ArkType, auto-coerces types. Drop-in dotenv replacement.
Type-safe environment variables. Loads .env files, validates with Zod/Valibot/ArkType, auto-coerces types. Drop-in dotenv replacement.
process.env is string | undefined, so you lose types immediately.npm install envtrue zod
pnpm add envtrue zod
yarn add envtrue zod
import { createEnv } from "envtrue";
import { z } from "zod";
const env = createEnv({
server: {
DATABASE_URL: z.string().url(),
PORT: z.number(), // auto-coerced from "3000" → 3000
API_KEY: z.string().min(1),
},
client: {
API_BASE: z.string().url(),
},
clientPrefix: "NEXT_PUBLIC_"
});
const db: string = env.DATABASE_URL; // typed as string
await connect(db, { port: env.PORT }); // typed as number
fetch(env.API_BASE);
| Feature | envtrue | t3-env |
|---|---|---|
Loads .env files for you | ✅ | ❌ |
Auto-coerces z.number(), z.boolean(), z.array() | ✅ | ❌ |
No runtimeEnv boilerplate | ✅ | ❌ |
| Framework-agnostic core | ✅ | ⚠️ |
envtrue is optimized for the common case: read .env, merge with runtime env, coerce strings into the right primitives, validate once, return typed values. No extra runtime mapping step.
The usual Zod setup is a small pile of repeated glue:
.env yourselfenvtrue keeps the schema but removes the glue. It auto-loads .env and .env.local, auto-coerces string inputs, separates client variables by prefix, and throws one formatted error with every invalid variable listed at once.
| Adapter | Import | Notes |
|---|---|---|
| Next.js | import { createNextEnv } from "envtrue/nextjs" | Uses NEXT_PUBLIC_, skips server validation in browser bundles, skips validation during Next build phases when needed |
| Vite | import { createViteEnv } from "envtrue/vite" | Uses VITE_, works with import.meta.env or process.env |
| Hono | import { createHonoEnv } from "envtrue/hono" | Server-only, supports explicit env bindings such as Cloudflare Workers / c.env |
createEnv(options)createEnv({
server,
client,
clientPrefix,
envFiles,
cwd,
env,
skipValidation,
onError
})
| Option | Type | Default | Description |
|---|---|---|---|
server | SchemaShape | {} | Server-only environment schema |
client | SchemaShape | {} | Client-safe environment schema |
clientPrefix | string | "NEXT_PUBLIC_" | Prefix required for client variables |
envFiles | string | string[] | [".env", ".env.local"] | .env files to load, in merge order |
cwd | string | process.cwd() | Base directory used to resolve envFiles |
env | Record<string, string | undefined> | process.env | Explicit runtime env source override |
skipValidation | boolean | false | Skip schema validation and return coerced raw values |
onError | (errors: EnvError[]) => void | throws formatted error | Hook for custom error handling |
.env files from disk.ArkType is supported through Standard Schema compatibility, but is not currently covered by the test suite.
.env support with dotenvx compatibility.env autocomplete and intellisenseMIT
FAQs
Type-safe environment variables. Loads .env files, validates with Zod/Valibot/ArkType, auto-coerces types. Drop-in dotenv replacement.
We found that envtrue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.