Installation
Get started with safe-env in seconds. Works with npm, yarn, pnpm, and bun.
Install Package
Using npm:
npm install @liahus/safe-envUsing yarn:
yarn add @liahus/safe-envUsing pnpm:
pnpm add @liahus/safe-envUsing bun:
bun add @liahus/safe-envDependencies
Note: zod is automatically installed as a dependency.
You don't need to install it separately. npm will handle it automatically.
Peer Dependencies
zod- Automatically installed- Node.js 18+ or Bun or Deno
Verify Installation
Create a test file to verify everything works:
import { env } from "@liahus/safe-env";
const ENV = env({
PORT: "number:default=3000",
});
console.log("✅ safe-env is working!");
console.log("PORT:", ENV.PORT, "(type:", typeof ENV.PORT, ")");Framework Support
Node.js
Bun
Deno
Next.js (App Router)
Next.js (Pages Router)
Express
Fastify
NestJS
Vite
Webpack
Remix
SvelteKit