Read-only access to the merged runtime environment.
Node and Bun use process.env; Deno uses Deno.env. The first matching
dotenv file is layered over that native environment. Browser imports use an
empty environment and never include server variables in client code.
import env from "@rcompat/env";env.get#
Returns the environment variable or the supplied fallback.
Parameters
key— Environment variable name.fallback— Value to return when the variable is missing.
Throws: Error when both the variable and fallback are undefined.
env.get<F extends NonNullable<unknown> | null = never>(
key: string, fallback?: F,
): string | F;env.has#
Checks whether an environment variable is defined.
Parameters
key— Environment variable name.
env.has(key: string): boolean;env.toJSON#
Returns a detached, mutable snapshot with a null prototype.
Returns: All loaded environment variables as a new dictionary.
env.toJSON(): Dict<string>;