g14o
Packages@g14o/env-core

API Reference

Types for createEnv and resolved env configuration.

CreateEnvOptions

OptionTypeDescription
server?TServer

Server-only variables; validated only when isServer is true.

client?TClient

Variables safe on the client; always validated unless skipValidation.

clientPrefix?TPrefix

Prefix every client key must use (enforced at compile time and runtime).

emptyStringAsUndefined?boolean | undefined

Treat "" as undefined before validation. Default false.

isServer?boolean | undefined

Override server detection. Default: no window on globalThis.

onInvalidAccess?OnInvalidAccessHandler

Called when a non-client key is read on the client. May throw a custom error; otherwise the default is thrown.

onValidationError?OnValidationErrorHandler

Called when schema validation fails. May throw a custom error; otherwise the default is thrown.

runtimeEnv?RuntimeEnvInput

Loose record to read values from (e.g. process.env). Extra keys are allowed.

runtimeEnvStrict?object

Explicit per-key mapping; mutually exclusive with runtimeEnv.

ResolvedCreateEnvOptions

OptionTypeDescription
clientTClient

Client-safe schema shape.

clientPrefixstring | undefined

Prefix every client key must use (enforced at compile time and runtime).

emptyStringAsUndefinedboolean

Treat "" as undefined before validation.

Default: `false`.
isServerboolean

Whether we're in a server context.

Default: `typeof window === "undefined"`.
onInvalidAccessOnInvalidAccessHandler | undefined

Called when a non-client key is read on the client. May throw a custom error; otherwise the default is thrown.

Default: `undefined`.
onValidationErrorOnValidationErrorHandler | undefined

Called when schema validation fails. May throw a custom error; otherwise the default is thrown.

Default: `undefined`.
runtimeRuntimeEnvInput

Record to read values from (e.g. process.env).

serverTServer

Server-only schema shape.

skipValidationboolean

Skip schema validation and return picked runtime values only.

Default: `false`.

On this page