Zod, Valibot, and other Standard Schema validators

Mix and match ArkType with Zod, Valibot, or other Standard Schema compatible libraries.

ArkEnv for Next.js supports any Standard Schema validator. That includes Zod, Valibot, Typia, and any validator listed here:

Flat layout

Here is an example using Zod or Valibot with the flat layout:

src/env.ts
import  from "./generated/env.gen";
import {  } from "zod";

export const  = ({
	: .().(),
	: .().(),
	: .(["development", "production", "test"]),
});
src/env.ts
import  from "./generated/env.gen";
import * as  from "valibot";

export const  = ({
	: .(.(), .()),
	: .(.(), .()),
	: .(["development", "production", "test"]),
});

Strict layout

You can freely mix Zod or Valibot schemas with the strict layout:

src/env/internal/shared.ts
import {  } from "zod";

/**
 * @internal 馃洃 INTERNAL SCHEMA ONLY.
 * Do not import this directly. Import `env` from `./client` or `./server` instead.
 */
export const  = .({
	: .(["development", "production", "test"]).("development"),
});
src/env/internal/shared.ts
import * as  from "valibot";

/**
 * @internal 馃洃 INTERNAL SCHEMA ONLY.
 * Do not import this directly. Import `env` from `./client` or `./server` instead.
 */
export const  = .({
	: .(.(["development", "production", "test"]), "development"),
});