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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@catgirls/env

v1.0.0

Published

Nyaa~! Environment variables, but make them type-safe! •⩊•

Readme

@catgirls/env 🐱

Nyaa~! Environment variables, but make them type-safe! •⩊•

What's This? uwu

A smol but powerful TypeScript library that makes handling environment variables not completely awful. It gives you:

  • Full type safety with runtime validation via Zod 🛡️
  • Clear separation of client/server env vars to avoid leaking secrets 🤫
  • Proper error messages when things go boom 💥
  • Zero-config transforms for common types like numbers and bools
  • Built-in transformers for quick type conversion 🔄

Installation

pnpm add @catgirls/env
# or yarn/npm if you must :3

Usage

swishes tail excitedly First, define your env config schema:

import { z } from "zod";
import { createServerEnv, transformers } from "@catgirls/env";

const env = createServerEnv({
  DATABASE_URL: {
    schema: z.string().url(),
  },
  PORT: {
    schema: z.number(),
    transform: transformers.number, // Using built-in transformer!
  },
  DEBUG_MODE: {
    schema: z.boolean().optional(),
    transform: transformers.optionalBoolean, // Optional transformer
  },
  FEATURE_FLAGS: {
    schema: z.object({
      enableNewStuff: z.boolean(),
    }),
    transform: transformers.json, // Type-safe JSON parsing
  },
});

// Typescript knows all the types! *purrs*
env.DATABASE_URL; // string
env.PORT; // number
env.DEBUG_MODE; // boolean | undefined

Built-in Transformers

Meow! We provide several built-in transformers to make your life easier:

// Numbers
transformers.number(val: string) => number
transformers.optionalNumber(val?: string) => number | undefined

// Booleans
transformers.boolean(val: string) => boolean
transformers.optionalBoolean(val?: string) => boolean | undefined

// JSON
transformers.json<T>(val: string) => T

For client-side envs (like Next.js), use createClientEnv instead:

const clientEnv = createClientEnv({
  NEXT_PUBLIC_API_URL: {
    schema: z.string().url(),
  },
});

Why This? (。♥‿♥。)

Because raw process.env makes me hiss. No types, no validation, everything's a string - it's like living in the JavaScript stone age! This little package fixes that with:

  • Runtime validation so things fail fast instead of in prod
  • Proper TypeScript types that actually match your runtime checks
  • Clear error messages when someone forgets required vars
  • Client/server separation to avoid accidentally exposing secrets
  • Built-in transformers for common type conversions

API

createServerEnv<T>

Server-side env validator that yells if you try to use it client-side.

createClientEnv<T>

Client-safe env validator that automatically prefixes keys with NEXT_PUBLIC_.

transformers

Collection of helper functions for common type conversions.

EnvValidationError

Pretty error when validation fails, with details about what went wrong.

License

MIT - Go wild! ₍⸍⸌̣ʷ̣̫⸍̣⸌₎


made with <3 by catgirls from vatican city

purrs contentedly at well-typed environment variables