lexmount:env
Read the immutable instance environment supplied for this execution.
lexmount:env provides instance variables for API endpoints, application settings, and credentials. It does not expose the host process: operating system environment variables are not automatically available to task code.
import env from 'lexmount:env';
const endpoint = env.API_URL;
if (!endpoint) throw new Error('Configure API_URL first');
console.log(await (await fetch(endpoint)).text());Default export env
Function: provides a frozen, read-only object for the current execution. The module has only a default export, with no get(), set(), or other configuration methods.
declare const env: Readonly<Record<string, string | undefined>>;Read a variable
Use env.KEY or env[key].
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | A configured variable name; case-sensitive |
Return value: a string when configured, or undefined when missing. Empty strings, whitespace, and newlines are preserved. Values are not automatically converted to numbers, booleans, or JSON; parse them explicitly when needed.
import env from 'lexmount:env';
const retries = Number(env.RETRIES ?? '3');
const enabled = env.ENABLED === 'true';
const apiKey = env['API_KEY'];
if (apiKey === undefined) throw new Error('Missing API_KEY');Configuration and snapshots
Edit key/value rows in the instance's Environment variables tab and save. Keys must start with a letter or underscore and contain only letters, digits, and underscores. Saving does not change values seen by an execution already in progress.
Each run submission captures a snapshot, retained through queueing and retries. Submit another run to use new configuration. Remove every row and save to clear the configuration. Code and variables share the run request size limit. Saved configuration can be displayed and edited in the console.
Read from an HTTP handler
A default-exported HTTP handler can also import this module. Its second argument is a separate frozen empty object; import env to read instance variables.
import env from 'lexmount:env';
export default {
fetch() {
return Response.json({ mode: env.MODE ?? 'default' });
},
};Because env is frozen, assigning or deleting properties cannot update configuration and throws TypeError in ES module strict mode. Storage backends and browser identity are platform configuration; application variables with matching names cannot override them.
See env.d.ts for the type declaration.
