# @t3-oss/env-nextjs

> ![NPM Version](https://img.shields.io/npm/v/%40t3-oss%2Fenv-core) [![JSR](https://jsr.io/badges/@t3-oss/env-core)](https://jsr.io/@t3-oss/env-core) [![JSR Score](https://jsr.io/badges/@t3-oss/env-core/score)](https://jsr.io/@t3-oss/env-core) [![Socket Bad

Latest version **0.13.11** (published 2026-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @t3-oss/env-nextjs
pnpm add @t3-oss/env-nextjs
yarn add @t3-oss/env-nextjs
bun add @t3-oss/env-nextjs
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.13.11 |
| Published | 2026-03-22 |
| First published | 2023-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4007 |
| Author | Julius Marminge |
| Maintainers | nexxel, juliusmarminge |
| Keywords | create-t3-app, environment variables, zod, nextjs |

## Links

- npm: https://www.npmjs.com/package/@t3-oss/env-nextjs
- Repository: https://github.com/t3-oss/t3-env
- Homepage: https://github.com/t3-oss/t3-env#readme
- Issues: https://github.com/t3-oss/t3-env/issues
- npm.io page: https://npm.io/package/@t3-oss/env-nextjs

## Dependencies (1)

- [@t3-oss/env-core](https://npm.io/package/@t3-oss/env-core.md) 0.13.11

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 0.13.11 (latest) — 2026-03-22
- 0.13.4-canary.2c99b41 (canary) — 2025-04-30
- 0.7.3-manual.2 (manual) — 2024-01-12
- 0.1.0-alpha.0 (alpha) — 2023-04-23
- 0.13.10 — 2025-12-15
- 0.13.9 — 2025-12-15
- 0.13.8 — 2025-06-09
- 0.13.7 — 2025-06-09
- 0.13.6 — 2025-05-27
- 0.13.5 — 2025-05-27
- 0.13.4 — 2025-04-30
- 0.13.3 — 2025-04-30
- 0.13.2 — 2025-04-30
- 0.13.1 — 2025-04-30
- 0.13.1-canary.c99c35e — 2025-04-30
- … 44 more at https://npm.io/package/@t3-oss/env-nextjs/versions

## README

# Typesafe Envs made Simple

![NPM Version](https://img.shields.io/npm/v/%40t3-oss%2Fenv-core)
[![JSR](https://jsr.io/badges/@t3-oss/env-core)](https://jsr.io/@t3-oss/env-core)
[![JSR Score](https://jsr.io/badges/@t3-oss/env-core/score)](https://jsr.io/@t3-oss/env-core)
[![Socket Badge](https://socket.dev/api/badge/npm/package/@t3-oss/env-core)](https://socket.dev/npm/package/@t3-oss/env-core/overview)

The Next.js package comes preconfigured for Next.js and also enforces some extra rules by default to make sure you have out-of-the-box compatibility in all different Next.js runtimes.

> For full documentation, see https://env.t3.gg

## Installation

```bash
# npm
npm i @t3-oss/env-nextjs

# pnpm
pnpm add @t3-oss/env-nextjs

# bun
bun add @t3-oss/env-nextjs

# deno
deno add jsr:@t3-oss/env-nextjs
```

## Usage

> [!NOTE]
>
> You may use any [Standard Schema](https://standardschema.dev) compliant validator of your choice. This example uses Zod

```ts
// src/env.ts
import { createEnv } from "@t3-oss/env-nextjs";
import * as z from "zod";

export const env = createEnv({
  /*
   * Serverside Environment variables, not available on the client.
   * Will throw if you access these variables on the client.
   */
  server: {
    DATABASE_URL: z.url(),
    OPEN_AI_API_KEY: z.string().min(1),
  },
  /*
   * Environment variables available on the client (and server).
   *
   * 💡 You'll get type errors if these are not prefixed with NEXT_PUBLIC_.
   */
  client: {
    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1),
  },
  /*
   * Specify what values should be validated by your schemas above.
   *
   * If you're using Next.js < 13.4.4, you'll need to specify the runtimeEnv manually
   * For Next.js >= 13.4.4, you can use the experimental__runtimeEnv option and
   * only specify client-side variables.
   */
  runtimeEnv: {
    DATABASE_URL: process.env.DATABASE_URL,
    OPEN_AI_API_KEY: process.env.OPEN_AI_API_KEY,
    NEXT_PUBLIC_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_PUBLISHABLE_KEY,
  },
  // experimental__runtimeEnv: {
  //   NEXT_PUBLIC_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_PUBLISHABLE_KEY,
  // }
});
```

---
_Source: https://npm.io/package/@t3-oss/env-nextjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
