Getting Started
Install nevr-env in your project:
sh
pnpm add nevr-envsh
npm install nevr-envsh
yarn add nevr-envsh
bun add nevr-envBasic Usage
nevr-env is framework agnostic — it works with Next.js, Vite, Express, Hono, Nuxt, Remix, Astro, SvelteKit, or any JavaScript runtime. Just set clientPrefix to match your framework and runtimeEnv to your env source.
Create a file env.ts (or env.js) in your project:
typescript
import { createEnv } from "nevr-env";
import { z } from "zod";
export const env = createEnv({
server: {
DATABASE_URL: z.string().url(),
API_SECRET: z.string().min(32),
NODE_ENV: z.enum(["development", "production", "test"]),
},
client: {
NEXT_PUBLIC_API_URL: z.string().url(),
},
clientPrefix: "NEXT_PUBLIC_",
runtimeEnv: process.env,
});Now import and use your environment variables:
typescript
import { env } from "./env";
// ✅ Type-safe access
console.log(env.DATABASE_URL); // string
console.log(env.NODE_ENV); // "development" | "production" | "test"
// ❌ TypeScript error - doesn't exist
console.log(env.NONEXISTENT);
// ❌ Runtime error on client - server variable accessed in browser
console.log(env.API_SECRET);Using Plugins
All official plugins are included with nevr-env - no extra installation needed:
typescript
import { createEnv, postgres, stripe } from "nevr-env";
import { z } from "zod";
export const env = createEnv({
plugins: [
postgres(),
stripe({ webhook: true }),
],
server: {
NODE_ENV: z.enum(["development", "production", "test"]),
},
runtimeEnv: process.env,
});
// Access plugin variables with full type safety
console.log(env.DATABASE_URL); // from postgres plugin
console.log(env.STRIPE_SECRET_KEY); // from stripe pluginAvailable Plugins
check out the Plugins Overview for the full list of available plugins and their options.
Tree-Shaking with Subpath Imports
If you want to optimize bundle size, use subpath imports:
typescript
import { createEnv } from "nevr-env";
import { postgres } from "nevr-env/plugins/postgres";
import { stripe } from "nevr-env/plugins/stripe";Interactive CLI Setup
Use the CLI wizard to set up environment variables:
sh
npx nevr-env initThe wizard will:
- Detect installed plugins
- Auto-discover values (e.g., Docker Postgres containers)
- Prompt for missing values
- Generate a
.envfile - Create type-safe configuration
Next Steps
- Why nevr-env? - Learn why we built this
- Plugins - Browse official plugins
- Creating Plugins - Build your own plugins
- Vault - Team secret sharing
- CLI Commands - Check, generate, scan, diff, rotate, CI
- Secret Scanning - Prevent accidental credential exposure
- Secret Rotation - Track when secrets need rotation
- Schema Diffing - Detect breaking changes between versions
- CI/CD Integration - Generate platform-specific CI configs
- Migration from t3-env - Upgrade guide