Connect with Puppeteer
Connect with Puppeteer.
Install
These pinned example dependencies require Node.js 22.12 or later.
npm install lexmount@0.5.17 puppeteer-core@25.12.0Set the credentials from getting started. Save this complete script as example.mjs, then run node example.mjs. No local browser download is required.
import puppeteer from 'puppeteer-core';
import { Lexmount } from 'lexmount';
const client = new Lexmount();
let session;
let browser;
try {
session = await client.sessions.create({ browserMode: 'normal' });
if (!session.connectUrl) throw new Error('Session has no CDP URL');
browser = await puppeteer.connect({ browserWSEndpoint: session.connectUrl });
const page = (await browser.pages())[0] ?? await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
console.log(await page.title());
} finally {
try {
await browser?.disconnect();
} finally {
try {
await session?.close();
} finally {
client.close();
}
}
}Expected output: Example Domain. The script connects to a remote Chromium session and closes the session even after a navigation failure. Treat the returned connection URL as a credential.
Continue with page interaction, content extraction, and lifecycle details.
