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

@scaffit/env

v1.0.5

Published

Environment variable setup with Zod validation for Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js projects

Downloads

2

Readme

@scaffit/env

Environment variable setup with Zod validation.

Features

  • Type-safe environment variables with Zod validation
  • Multi-framework support - Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js
  • Automatic framework detection - Adapts configuration based on your project
  • Example variables included for common use cases
  • Feature-based configuration - Choose what to include (database, auth, APIs, etc.)

Installation

Option 1: Using Scaffit CLI (Recommended)

# Add environment scaffold (no installation needed!)
npx scaffit add env

Alternative: Global Installation

# Install CLI globally
npm install -g scaffit

# Add environment scaffold
scaffit add env

Option 2: Direct npm package usage

# Install scaffold directly
npm install @scaffit/env

# Use in your code
import { setupEnv, previewEnv } from '@scaffit/env';

// Setup environment variables with custom options
const result = await setupEnv({
  includeExamples: true,
  useZod: true,
  features: ['database', 'auth', 'apis'],
  projectRoot: './my-project'
});

// Preview changes before applying
const preview = await previewEnv({
  useZod: true,
  features: ['database', 'auth']
});

Note: Both approaches require @scaffit/core to be installed (automatically handled).

Usage

After installation, you can immediately use environment variables:

# Copy the example file and fill in your values
cp .env.example .env.local

# Your environment variables are now validated and type-safe

Note: Environment setup is ready to use immediately after installation.

Configuration Options

  • Use Zod validation: Add Zod schema validation for environment variables
  • Include examples: Add common environment variable examples
  • Select features: Choose from database, auth, APIs, email, storage, analytics
  • Framework: Automatically detected (Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js)

Generated Files

.env.example

Template file with example environment variables (framework-specific):

Next.js:

# Next.js Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/database"

# API Keys
OPENAI_API_KEY="your-openai-key-here"
STRIPE_SECRET_KEY="your-stripe-secret-key"

React/Vue/Svelte:

# React/Vue/Svelte Configuration
VITE_API_URL="http://localhost:3000"

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/database"

# API Keys
OPENAI_API_KEY="your-openai-key-here"
STRIPE_SECRET_KEY="your-stripe-secret-key"

Express/Fastify/Node.js:

# Express/Fastify Configuration
PORT=3000
NODE_ENV="development"

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/database"

# Authentication
JWT_SECRET="your-jwt-secret-here"
SESSION_SECRET="your-session-secret-here"

env.ts / env.js

Type-safe environment validation (framework-specific):

Next.js:

import { z } from 'zod';

const envSchema = z.object({
  NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
  NEXTAUTH_URL: z.string().url(),
  NEXTAUTH_SECRET: z.string().min(32),
  DATABASE_URL: z.string().url(),
  OPENAI_API_KEY: z.string().optional(),
  STRIPE_SECRET_KEY: z.string().optional(),
});

export const env = envSchema.parse(process.env);
export type Env = z.infer<typeof envSchema>;

React/Vue/Svelte:

import { z } from 'zod';

const envSchema = z.object({
  NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
  VITE_API_URL: z.string().url(),
  DATABASE_URL: z.string().url(),
  OPENAI_API_KEY: z.string().optional(),
  STRIPE_SECRET_KEY: z.string().optional(),
});

export const env = envSchema.parse(process.env);
export type Env = z.infer<typeof envSchema>;

Express/Fastify/Node.js:

import { z } from 'zod';

const envSchema = z.object({
  NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
  PORT: z.string().default('3000'),
  DATABASE_URL: z.string().url(),
  JWT_SECRET: z.string().min(32),
  SESSION_SECRET: z.string().min(32),
  OPENAI_API_KEY: z.string().optional(),
  STRIPE_SECRET_KEY: z.string().optional(),
});

export const env = envSchema.parse(process.env);
export type Env = z.infer<typeof envSchema>;

Dependencies Added

  • zod - Schema validation for environment variables

Next Steps

  1. Copy .env.example to .env.local
  2. Fill in your actual environment variables
  3. Import env in your application files
  4. Use type-safe environment variables throughout your app

Example Usage

import { env } from './env';

// Type-safe access to environment variables
const dbUrl = env.DATABASE_URL; // string
const secret = env.NEXTAUTH_SECRET; // string