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

@nifrajs/env

v3.1.0

Published

Typed, validated environment variables for nifra - define a schema, get a frozen typed object, fail loud at boot listing every problem. Coercing helpers (number/port/boolean/url/enum) + any Standard Schema. Dependency-free, edge-safe.

Readme

@nifrajs/env

Typed, validated environment variables. Define a schema once at startup; get a frozen, typed object - or a loud boot-time failure listing every problem at once, so a misconfigured deploy fails immediately instead of erroring on the first request that touches a bad var. The config half of nifra's "validate at every boundary" rule. Dependency-free, edge-safe.

// env.ts - imported once at startup
import { defineEnv, env } from "@nifrajs/env"

export const ENV = defineEnv({
  DATABASE_URL: env.url(),
  PORT: env.port({ default: 3000 }),
  NODE_ENV: env.enum(["development", "production", "test"], { default: "development" }),
  STRIPE_SECRET: env.string(),
  DEBUG: env.boolean({ default: false }),
  SENTRY_DSN: env.url({ optional: true }),
})

// ENV.PORT      → number
// ENV.NODE_ENV  → "development" | "production" | "test"
// ENV.DEBUG     → boolean
// ENV.SENTRY_DSN → string | undefined

A missing/invalid var fails at import:

[nifra/env] invalid environment - 2 problem(s):
  DATABASE_URL: must be a valid URL
  STRIPE_SECRET: is required

Set the variable(s) above and restart.

Coercing helpers

Every value in process.env is a string | undefined; these turn it into the value you want:

| helper | type | notes | | --- | --- | --- | | env.string({ default?, optional? }) | string | empty string counts as unset | | env.number({ default?, optional? }) | number | finite, coerced | | env.port({ default? }) | number | integer 1-65535 | | env.boolean({ default? }) | boolean | true/1/yes/on vs false/0/no/off/empty | | env.enum([...], { default? }) | union | one of the listed values | | env.url({ default?, optional? }) | string | parses with WHATWG URL, returns the normalized href |

optional: true makes the type T | undefined; default supplies a fallback when unset.

Bring your own validator

defineEnv accepts any Standard Schema (t from @nifrajs/schema, zod, valibot), not just the env.* helpers - handy for a shape the helpers don't cover. Only the env.* helpers coerce from strings, though: a plain t.number() would see the raw string, so reach for env.number() when you need coercion.

Edge runtimes

defineEnv reads process.env by default (Bun/Node). Cloudflare Workers has no process.env - pass the request's bindings: defineEnv(shape, { source: env }).

Secret safety

Error messages name the offending variable and the reason - never its value (it may be a secret). defineEnv returns a frozen object, so a validated config can't be mutated downstream.

For AI agents

Start with LLM.md - this package's contract card (the exports you call + its footguns), one cheap read instead of the whole corpus. For the wider framework: the repo's AGENTS.md is the copy-paste quick reference, and llms-full.txt is the full machine-readable corpus. Run nifra check as the done-gate, or nifra mcp to give the agent live project tools.