Node.js Quick Start
Create Chromium and Moli sessions and connect to Chromium with Playwright.
Prepare credentials first
Create an API Key and copy its Project ID from Settings → API Keys. You can verify the same flow in the console quick start before running code.
1. Install
npm install lexmount playwright dotenv
npx playwright install chromium2. Configure credentials
export LEXMOUNT_API_KEY=<your-api-key>
export LEXMOUNT_PROJECT_ID=<your-project-id>
# Optional; defaults to the CN API
export LEXMOUNT_BASE_URL=https://api.lexmount.cn3. Create and control Chromium
import { chromium } from "playwright";
import { Lexmount } from "lexmount";
const client = new Lexmount();
const session = await client.sessions.create({ browserMode: "normal" });
try {
console.log("session:", session.id);
console.log("view:", session.inspectUrl);
const browser = await chromium.connectOverCDP(session.connectUrl);
const context = browser.contexts()[0];
const page = context?.pages()[0] ?? (await context?.newPage());
if (!page) throw new Error("No page is available");
await page.goto("https://example.com", { waitUntil: "domcontentloaded" });
console.log("title:", await page.title());
await browser.close();
} finally {
await session.close();
client.close();
}Always close the session in finally so a browser is not left running after an exception.
4. Create Moli
Moli is the product name for the stable SDK/API value light:
const session = await client.sessions.create({
browserMode: "light",
enableLightmountLayout: true,
enableLightmountResource: true,
});Use Moli for lightweight agent browsing and content-oriented tasks. Persistent replay is always disabled for Moli. Use Chromium when a task depends on the full persistent-browser feature set.
5. Know the defaults
| Behavior | Current default |
|---|---|
| Session create path | Async create, polling until active |
| Activation timeout | 600 seconds |
| Stored downloads | Enabled unless downloads: { enabled: false } |
| Chromium persistent replay | Enabled by the current platform unless explicitly disabled |
| Moli persistent replay | Always disabled |
| Region | Default catalog region when available; otherwise the configured base URL |
Explicitly disable artifacts that the task does not need:
const session = await client.sessions.create({
browserMode: "normal",
downloads: { enabled: false },
recording: { persistent: false },
});6. Select a region
const client = new Lexmount({ region: "<region-id>" });
console.log(await client.regionInfo());
console.log(await client.catalogInfo());
client.close();If catalog lookup or host probing is unavailable, the SDK falls back to LEXMOUNT_BASE_URL.
Troubleshooting
- Authentication error: confirm the API Key and Project ID come from the same project.
- Create timeout: inspect the exception and console session list before retrying; async create may already have reserved a session ID.
- View works but Playwright does not connect: confirm the session is active and your network can reach
session.connectUrl. - Resources remain active: close both the browser connection and session in
finally.
Continue with Node.js Capabilities or run a script from Node.js Examples.
Lexmount Browser