npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

env-ready

v2.2.0

Published

A schema-driven environment variable loader for Node.js projects

Readme

env-ready

Test Status Test Coverage npm semantic-release: angular

env-ready provides a centralized, fail-fast mechanism for validating environment variables at startup—designed to reduce misconfiguration, improve safety, and support your preferred schema validation library through validator inference.

Why env-ready?

  • Type-safe by design: Built with TypeScript for first-class static validation
  • Fail-fast startup: Surface configuration errors early, not during execution
  • Schema-agnostic architecture: Bring your own validator (zod, joi, etc.)
  • Minimal runtime footprint: Focused, purpose-built utility with no bloat

Goals

  • Centralize environment variable validation and access
  • Fail fast on missing or malformed variables
  • Enable schema flexibility through validator inference
  • Keep the runtime overhead minimal and the API ergonomic

Installation

npm install env-ready

Usage

Basic Example

Create a schema using your preferred validation library, for instance, in src/env.ts:

import { loadEnv } from "env-ready"
import { z } from "zod"

// Define your schema using Zod
const schema = z.object({
  FOO: z.string().min(1, "FOO is required"),
  BAR: z.number().optional(),
})

// Load and validate environment variables
export const env = loadEnv(schema)

Then, in your application code:

import { env } from "./env"

console.log(env.FOO) // Access validated environment variable
console.log(env.BAR) // Optional variable, may be undefined

Joi Schemas

Joi schemas are fully supported, but type inference is not available by default. To coerce Joi schemas into TypeScript types, you can use the joi-to-typescript package or manually define types that match your Joi schema.

JavaScript Example

const { loadEnv } = require("env-ready")
const Joi = require("joi")

// Define your Joi schema
const schema = Joi.object({
  FOO: Joi.string().required(),
  BAR: Joi.number(), // Optional by default
})

// Load and validate environment variables
const env = loadEnv(schema) // `env` will be typed as `any`
console.log(env.FOO) // Access validated environment variable
console.log(env.BAR) // Optional variable, may be undefined

TypeScript Example

import { loadEnv } from "env-ready"
import Joi from "joi"

// Define your Joi schema
const schema = Joi.object({
  FOO: Joi.string().required(),
  BAR: Joi.number(), // Optional by default
})

// Define TypeScript types based on your Joi schema
type EnvConfig = {
  FOO: string
  BAR?: number // Optional variable
}

// Load and validate environment variables
const env = loadEnv<EnvConfig>(schema) // `env` will be typed as `EnvConfig`
console.log(env.FOO) // Access validated environment variable
console.log(env.BAR) // Optional variable, may be undefined

Custom Schemas

You can also create custom schemas that implement the parse method:

import { loadEnv } from "env-ready"

// Define a custom schema class
class CustomSchema<T> {
  parse(env: unknown): T {
    // Custom parsing logic here
    return env as T
  }
}

// Define your custom schema type
type MyConfig = { FOO: string; BAR?: number }

// Create an instance of your custom schema
export const mySchema = new CustomSchema<MyConfig>()

// Load and validate environment variables using your custom schema
export const env = loadEnv(mySchema)

Validator Compatibility

  • Zod
  • Joi
  • Custom schemas
    • Must implement: parse<T>(env: unknown): T

Contribute

If you find this project useful, consider:

  • Starring the repository to improve visibility
  • Using it in your projects and sharing feedback
  • Opening issues for bugs, ideas, or validator support requests

Early adoption helps refine the direction and expand validator support. Thanks for your support!