Browser API
Work with the top-level browser, contexts, and pages.
Launch
ts
import { chromium } from "@quitecode/chromium-automaton";
const browser = await chromium.launch({
headless: false, // default is true
maximize: true, // adds --start-maximized
args: process.platform === "linux" ? ["--no-sandbox"] : []
});Options:
headless(defaulttrue)maximizeadds the Chromium flag--start-maximizedargsextra Chromium flagstimeoutMsfor startuplogLevel,logEvents,logActions,logAssertionsuserDataDirto reuse a profile; defaults to an isolated temp profile per launchexecutablePathto point at an existing Chromium build
Contexts
ts
const context = await browser.newContext(); // fresh incognito-style profile
const page = await context.newPage();Contexts isolate cookies, storage, and tabs. Closing a context disposes its pages.
Pages
ts
const page = await browser.newPage(); // uses the default context
await page.goto("https://example.com");Use additional pages to run tabs in parallel within the same profile.
Close
ts
await browser.close(); // shuts down all contexts and Chromium