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

@ma.vu/env

v0.2.2

Published

Zero-dependency env validation with builder API

Readme

@ma.vu/env

Zero-dependency env validation with a builder API. Type-safe, no schema library needed.

npm

Why

Env vars are strings. You need to know: is it present? What type? Any length constraints? That's it. No reason to pull in a schema library for that.

  • Zero runtime dependencies
  • Full TypeScript inference — parse() returns typed data matching your schema
  • Immutable builder API — .min(), .max() return new descriptors
  • parse() throws on missing required vars, warns on missing optional vars

Install

npm install @ma.vu/env

Usage

Define a schema

// config/env.config.ts
import { createEnv, required, optional, number, boolean } from '@ma.vu/env';

export const env = createEnv({
  CLERK_SECRET_KEY: required,
  API_KEY: required.min(5).max(100),
  DATABASE_URL: optional,
  PORT: number,
  DEBUG: boolean,
});

Use in your app

// config/app.config.ts
import { env } from './env.config';

const { data, warnings } = env.parse(process.env);
// Throws if required vars are missing
// Warns about missing optional vars

export const config = data;
// config.CLERK_SECRET_KEY → string
// config.PORT             → number
// config.DEBUG            → boolean

Generate .env in CI

// bin/validate-env.ts
import { env } from '../src/server/config/env.config.js';

const source = JSON.parse(process.argv[2]);
env.writeEnvFile({ source, output: process.argv[3] });
- name: Generate and validate .env
  run: npx tsx bin/validate-env.ts '${{ toJSON(secrets) }}' .env.deploy

toJSON(secrets) dumps all GitHub secrets as a JSON string. The script parses it, validates against the schema (throws on errors), and writes a .env file. Empty optional values are skipped.

API

Primitives

| Export | Type | Behavior | |------------|---------|-------------------------------------------------| | required | string | Trimmed, must be non-empty (min length 1) | | optional | string | Trimmed, defaults to "", appears in warnings if missing | | number | number | Coerced via Number(), error if NaN | | boolean | boolean | "true"/"1" → true, "false"/"0"/"" → false |

Modifiers

.min(n) and .max(n) return new descriptors (immutable):

required            // trimmed, min 1
required.min(5)     // trimmed, min 5
required.max(100)   // trimmed, max 100
optional.max(255)   // trimmed, defaults "", max 255 if provided
number.min(1).max(65535) // numeric range

createEnv(schema)

Returns an object with:

  • parse(source) — validates source against the schema. Throws on errors, warns on missing optional. Returns { data, warnings }
  • writeEnvFile({ source, output }) — validates and writes a .env file. Throws on errors
  • keys — array of all keys from the schema

License

MIT