Logo of LexmountLexmount Docs
Logo of LexmountLexmount Docs
Homepage

Introduction

Documentation Overview
Node.js SDKNode.js SDK Quick StartCapabilitiesNode.js Examples
X (Twitter)
Node.js SDK

Node.js Examples

Explain Node.js examples by quickstart flow, use case, command, and expected result.

Start with playwright-basic.ts. It maps to the minimal quickstart loop: create session, connect over CDP, visit a page. Other examples extend that base flow.

Before running examples

npm install
npm run build

cp .env.example .env
# Fill LEXMOUNT_API_KEY and LEXMOUNT_PROJECT_ID

cd examples
npm install

Common environment variables:

LEXMOUNT_API_KEY=sk_...
LEXMOUNT_PROJECT_ID=project_...
LEXMOUNT_BASE_URL=https://api.lexmount.cn
LEXMOUNT_EXTENSION_PATH=/absolute/path/to/extension.zip
LEXMOUNT_PROXY_SERVER=http://host:port
LEXMOUNT_PROXY_USERNAME=optional
LEXMOUNT_PROXY_PASSWORD=optional

Recommended order

OrderExamplePurpose
1playwright-basic.tsCreate session, connect browser, visit page
2session-management.tsCreate multiple sessions and list active sessions
3session-downloads.tsRetrieve downloaded files from the remote browser
4context-basic.tsCreate and reuse browser context
5context-list-get.tsInspect context list and detail
6context-modes.tsUnderstand readWrite / readOnly access
7context-lock-handling.tsHandle context lock conflicts
8extension-basic.tsUpload and mount Chrome extension
9proxy-session.tsCreate session with custom proxy

playwright-basic.ts: minimal browser loop

Run:

npm run playwright-basic

It creates a normal browser session, connects to the remote browser through connectUrl, opens https://example.com, and prints the title. Run this first for a new integration.

session-management.ts: manage sessions

Run:

npm run session-management

It creates normal and light sessions, then lists active sessions. Use it to understand parallel browsers, pagination, and session metadata.

session-downloads.ts: retrieve downloads

Run:

npm run session-downloads

It configures remote browser download behavior, triggers a download, then queries metadata and retrieves one file or all files as an archive.

Context examples

npm run context-basic
npm run context-list-get
npm run context-modes
npm run context-lock-handling

These examples focus on reusing browser data:

  • context-basic.ts: create a context and mount it to a session.
  • context-list-get.ts: inspect context metadata and status.
  • context-modes.ts: show read-write and read-only access.
  • context-lock-handling.ts: handle lock errors and retry metadata.

extension-basic.ts: extension support

Run:

npm run extension-basic

After setting LEXMOUNT_EXTENSION_PATH, the script uploads an extension zip and mounts it with extensionIds when creating a session.

proxy-session.ts: custom proxy

Run:

npm run proxy-session

After setting proxy environment variables, the script creates a proxied remote browser and verifies that browser traffic uses the proxy.

Troubleshooting

  • If session creation fails, check API Key, Project ID, and project quota.
  • If Playwright cannot connect, print session.connectUrl and confirm the session was not closed early.
  • If a context is locked, inspect activeSessionId and retryAfter, then retry after the active session releases it.

Capabilities

Session, context, extension, download, logging, and error capabilities exposed by the Node.js SDK.

Table of Contents

Before running examples
Recommended order
playwright-basic.ts: minimal browser loop
session-management.ts: manage sessions
session-downloads.ts: retrieve downloads
Context examples
extension-basic.ts: extension support
proxy-session.ts: custom proxy
Troubleshooting