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 a required environment variable.
Parameters
key— Environment variable name.
Throws: Error when the variable is not defined.
env.get(key: string): string;env.try#
Returns an optional environment variable.
Parameters
key— Environment variable name.
Returns: The value, or undefined when it is not defined.
env.try(key: string): string | undefined;env.toJSON#
Returns a detached, mutable snapshot with a null prototype.
Returns: All loaded environment variables as a new dictionary.
env.toJSON(): Dict<string>;