Installation

Get started with safe-env in seconds. Works with npm, yarn, pnpm, and bun.

Install Package

Using npm:

npm install @liahus/safe-env

Using yarn:

yarn add @liahus/safe-env

Using pnpm:

pnpm add @liahus/safe-env

Using bun:

bun add @liahus/safe-env

Dependencies

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

Next Steps

1. Quick Start

Learn how to create your first environment schema.

Go to Quick Start →

2. DSL Syntax

Understand the simple DSL for defining your schema.

Learn DSL Syntax →