Skip to navigation

Browser Runtime Quickstart

View as Markdown

Launch a cloud browser, automate it with Playwright, and let BCTRL record the whole run. This recipe uses your own Playwright code over a CDP connection - no hosted agent required.

import { Bctrl } from "@bctrl/sdk";
import { chromium } from "playwright";
const bctrl = new Bctrl({ apiKey: process.env.BCTRL_API_KEY! });
// Launch a cloud browser runtime
const runtime = await bctrl.runtimes.create({ type: "browser", name: "quickstart" });
const { connection, runId } = await bctrl.runtimes.start(runtime.id);
// Drive it with Playwright over CDP
const browser = await chromium.connectOverCDP(connection.cdpUrl);
const context = browser.contexts()[0] ?? (await browser.newContext());
const page = context.pages()[0] ?? (await context.newPage());
try {
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await browser.close();
await bctrl.runtimes.stop(runtime.id);
}
// Everything was recorded on the run
const events = await bctrl.runs.events.list(runId);
console.log(`${events.data.length} events recorded`);

The runtime runs on BCTRL infrastructure. Playwright connects through the run-scoped cdpUrl, and BCTRL captures the session as a run - events, live view, recording, and files - with nothing to wire up.

Next