Environment Variables
Imported from "void/env". Declare your environment variables once and read them with types.
On this pageDefine a schema with defineEnv · Read typed values from env · Use the schema helpers
defineEnv(schema)
Registers an env schema and returns the typed env proxy. The SDK finds env.ts on its own and imports it in dev, build and deploy. It generates .void/env.d.ts. It checks production secrets before deploy and checks values when the Worker starts.
import { defineEnv, string, number, oneOf, url } from 'void/env';
export default defineEnv({
STRIPE_KEY: string(),
PORT: number().default(3000),
NODE_ENV: oneOf(['development', 'production']),
VITE_PUBLIC_URL: url(),
});env
A typed runtime proxy for declared env keys. Unknown keys and bindings pass through as unknown.
import { env } from 'void/env';
const port = env.PORT;Schema helpers
void/env includes Standard Schema-compatible helpers: string(), number(), boolean(), url(), email(), oneOf([...]), and json<T>(). Each helper supports .optional() and .default(value).
Keys without VITE_ are server values. In production they use remote secret storage. VITE_* keys are public client values set at build time. Invalid input is always redacted. Schema modifiers do not choose the storage.
Types
void/env also provides global Cloudflare environment types:
/// <reference types="void/env" />Declares the Cloudflare.Env namespace with DB, KV, STORAGE, AI and SANDBOX binding types.
For handler context variables such as c.set() and c.get(), augment CloudContextVariables. This is separate from Cloudflare.Env, which types Worker bindings. Framework adapters such as @void/vue, @void/react and @void/svelte also augment CloudContextVariables. They add the shared key that useShared() uses.