Skip to content

zod-envkit


mustLoadEnv<T>(schema): output<T>

Defined in: index.ts:104

Fail-fast wrapper around loadEnv.

Equivalent to: loadEnv(schema, { throwOnError: true }) but returns typed env directly.

Type Parameters

T

T extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Parameters

schema

T

Returns

output<T>

Remarks

Load dotenv (e.g. import "dotenv/config") before calling so process.env is populated.

See

loadEnv — returns a result object instead of throwing.

Example

ts
export const env = mustLoadEnv(EnvSchema);

Throws

ZodError

Since

1.0.5

Released under the MIT License.