Skip to main content

Function: getEnvVar()

getEnvVar(key): string

Defined in: base/os.ts:93

Retrieves the value of an environment variable in a cross-runtime way.

Deno / Node.js: reads directly from the process environment.

Browser: browsers have no native environment variables. GoatDB proxies GOATDB_* variables through the GoatDBConfig global that the server injects into the JS bundle. The GOATDB_ prefix is stripped and the remainder is lowercased to form the lookup key (e.g. GOATDB_SUITEGoatDBConfig.suite). Keys that do not start with GOATDB_ always return undefined in the browser — call this function from server-side code (Deno or Node.js) for non-GOATDB_* keys.

Parameters

ParameterTypeDescription
keystringThe environment variable name (e.g., "GOATDB_SUITE").

Returns

string

The value of the variable, or undefined if not set.