Quickstart
Run JavaScript projects, associate persistent storage, debug executions, and connect your computer or server from the console.
This guide uses the web console. To deploy a local project from the terminal, see CLI tools.
Run in the console
- Open Instances, select Create instance, and optionally enter a name.
- Paste the JavaScript below into the new instance's code tab, set the maximum runtime to 10 seconds, and select Run.
- Read the output in Overview and confirm that the execution succeeded in its history.
const response = await fetch('https://example.com');
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const html = await response.text();
console.log(JSON.stringify({ status: response.status, characters: html.length }));The instance stops automatically after the script finishes. Its code and history remain available for another run. Runtime limits start when code actually begins executing; 0 means unlimited.
Inspect results and run again
Return to Instances and select an instance
After running, switch to Overview and read the status code and character count in Output logs. Logs update automatically; script errors also appear here.
Check the execution's status and finish time in Execution history. A success state confirms completion. For failures or timeouts, inspect the logs for the cause. Creating an instance or selecting Run still requires waiting for the execution result.
To change the task, open Code, edit it, and select Run again. You can also select Load code in execution history to bring historical code into the editor before editing and running it. Each execution uses a fresh JavaScript environment without global variables from earlier runs.
Stop, delete, and find instances
- Stop: select Stop in the instance list or on the detail page's Code tab. After cleanup, the instance shows as ended; its code, history, and logs remain available.
- Batch stop: select instances in the list and use Stop selected, or stop all your active instances with Stop all.
- Delete: select Delete in the instance list and confirm. This stops and cleans up the instance before deleting code, execution history, and logs. Associated storage resources and their data are preserved. Deletion cannot be undone. If cleanup is still pending, retry later.
- Find: filter by state or enter a full instance ID for an exact lookup. Open an instance's Overview to edit its name.
Debug an instance
While an instance is running and reachable, open its detail page and select Inspect to open DevTools. In Sources, open your entry file, such as main.mjs, and set a breakpoint, then trigger an HTTP request or an asynchronous callback. Use Console to evaluate expressions and inspect values. To use your own CDP client, select Copy CDP and connect to the copied WebSocket address. The address is fixed for the instance and has no expiry; anyone with it can debug the current execution without an API key or ticket, so keep it private.
Stopping or running the instance again disconnects the debugger. Reconnect for the new execution; the instance address stays the same. Pausing still counts toward the maximum runtime. This is attach-to-running debugging: code that has already finished cannot be inspected. Synchronous Console evaluations skip breakpoints; to pause from Console, schedule a callback such as setTimeout(() => { debugger; }, 50).
Use your computer or server
Download the native client for your platform from Clients and extract it. See the CLI tools guide for connection settings, background operation, and automatic startup.
Get your API key and project ID from API Keys on this site to connect the client. For macOS / Linux:
export LEXMOUNT_API_KEY='<your-api-key>'
export LEXMOUNT_PROJECT_ID='<your-project-id>'
export LEXMOUNT_BASE_URL='https://api.lexmount.cn'
./runtime-cli daemon startIn Windows PowerShell, set $env:LEXMOUNT_API_KEY='...', $env:LEXMOUNT_PROJECT_ID='...', and $env:LEXMOUNT_BASE_URL='https://api.lexmount.cn', then run .\runtime-cli.exe daemon start.
Keep the client running, copy its full ID from the management page, and replace <client-id> in the remote examples. Scripts run in the cloud runtime; runtime-cli performs remote operations on that computer.
File writes are disabled by default; command execution is enabled by default. See client capabilities and permissions for the controls and their scope.
Debug a client in the console
- Find an online, reachable client on Clients and select Debug.
- Choose a module and operation. For example, use the file system's readDir operation with path
.to inspect the client's startup directory. - Select Generate code, review the generated JavaScript, and select Run debug code.
- The console creates an instance and opens its details. Read the result in Overview's output logs.
The debug panel also supports HTTP requests, process queries and execution, TCP connections and listeners, and HTTP services. Before writing files or executing commands, confirm the relevant permissions are applied through the client's Configure dialog. Use the examples to compose several operations into your own task.
Multiple files and images
In Code, use Import files or Import directory to upload a project, or create files in the editor. Directory imports retain relative paths and skip .git and node_modules. Select a JS/MJS entry; by default, the root main.js takes precedence over main.mjs. Both static and dynamic local imports work, for example import { value } from './lib/value.mjs'.
Each file and the complete project must fit within 8 MiB of original bytes. Images count by their original size. Loading an execution from history restores all its files and entry. Unsubmitted file edits are saved as local drafts for seven days, separately for each account and instance; restore them after reloading the page. A successful submission clears that draft.
Import an uploaded image as a Binary Module and return its default ArrayBuffer export from your HTTP handler:
import image from './assets/logo.png';
export default {
fetch() {
return new Response(image, {
headers: { 'content-type': 'image/png' },
});
},
};Paths resolve relative to the importing file and must include extensions. Dynamic import() also works: const { default: image } = await import('./assets/logo.png'). Local files other than JS/MJS load as binary bytes, including text and JSON files; decode or parse them in your code. Uploading an image alone does not create a public URL.
Keep data across runs
- Open Storage management and select Databases, Object storage, or KV storage.
- Create a named resource. For the KV example, select KV storage and create
cache. - Create an instance, or stop an existing one and wait for cleanup to finish.
- In its Storage tab, select the matching storage type, choose the resource, and select Associate KV storage (or the corresponding database/object storage action).
- Run the example using that exact resource name and inspect its output logs. Another instance with the same association can access the saved data.
Each run has a fresh JavaScript environment, while associated storage persists. Removing an association or deleting an instance keeps the resource and data. Deleting a resource requires removing every association first. Read the storage reference for sharing, size limits, TTL, and deletion behavior.
Execution environment
Task code executes as an ES module, with top-level await, dynamic import(), and local JS/MJS modules. CommonJS, Node.js built-ins, node_modules resolution, and application TypeScript/JSX transpilation are unavailable. Editor completion does not enable TypeScript submissions.
| Capability | Available interfaces |
|---|---|
| Requests and responses | fetch, Request, Response, Headers, FormData, Blob, File |
| URLs | URL, URLSearchParams, URLPattern |
| Encoding and streams | TextEncoder, TextDecoder, ReadableStream, WritableStream, TransformStream, CompressionStream |
| Async work and cancellation | setTimeout, setInterval, queueMicrotask, AbortController, AbortSignal |
| Other Web APIs | crypto / WebCrypto, WebSocket clients, structuredClone, atob / btoa, event basics |
| Logs and arguments | console.log/info/warn/error/debug; jsd.args is empty in task mode |
| Built-in modules | lexmount:env, lexmount:storage, lexmount:remote, lexmount:browser |
Global fetch allows only public HTTP(S) destinations. Use host.fetch for services on a client's own machine or private network. See the API Reference for methods, parameters, and return values.
Tasks finish when all active resources end. HTTP servers, timers, and network work can keep an execution active. An isolated, unawaited promise does not independently keep it alive. Every rerun uses a new JavaScript environment without prior globals; persist data in associated storage resources.
