Beignet API reference
    Preparing search index...

    Interface CreateEnvOptions<Server, ClientPrefix, Client>

    Options for createEnv(...).

    interface CreateEnvOptions<
        Server extends EnvSchemaShape,
        ClientPrefix extends string,
        Client extends EnvSchemaShape,
    > {
        client?: Client & ValidateClientEnvShape<
            NoInferType<ClientPrefix>,
            Client,
        >;
        clientPrefix?: ClientPrefix;
        emptyStringAsUndefined?: boolean;
        isServer?: boolean;
        onInvalidAccess?: (key: string) => never;
        onValidationError?: (issues: readonly Issue[]) => never;
        runtimeEnv?: RuntimeEnv;
        runtimeEnvStrict?: RuntimeEnv;
        server?: Server;
        skipValidation?: boolean;
    }

    Type Parameters

    Index

    Properties

    client?: Client & ValidateClientEnvShape<NoInferType<ClientPrefix>, Client>

    Client-safe environment variables. Keys must use clientPrefix when a prefix is provided.

    clientPrefix?: ClientPrefix

    Prefix required for client variables, e.g. NEXT_PUBLIC_.

    emptyStringAsUndefined?: boolean

    Treat empty strings as missing values before validation.

    Defaults to true for createEnv because it keeps defaults ergonomic in framework starters.

    isServer?: boolean

    Override server detection. Defaults to checking for window on globalThis.

    onInvalidAccess?: (key: string) => never

    Called when a server-only variable is read from a client runtime.

    onValidationError?: (issues: readonly Issue[]) => never

    Called when validation fails. Throw from this hook to customize the error.

    runtimeEnv?: RuntimeEnv

    Runtime environment object. Defaults to process.env when available.

    runtimeEnvStrict?: RuntimeEnv

    Strict runtime environment object. Every declared key must be present on the object, even if the value is undefined. This catches framework bundling mistakes where an env var was not explicitly accessed.

    server?: Server

    Server-only environment variables. These throw if accessed from a client runtime through the returned env object.

    skipValidation?: boolean

    Skip validation and return raw values. Use sparingly for build phases where deployment secrets are unavailable.