Browser
The Browser entity launches a headless Chromium browser via Playwright, exposing a WebSocket endpoint for remote automation.
Prerequisites
Section titled “Prerequisites”Install the Chromium binary (one-time setup):
bunx playwright install chromiumImport
Section titled “Import”import { Browser } from "sigil";Constructor
Section titled “Constructor”new Browser(name: string, config?: Partial<Omit<BrowserConfig, "name">>)Config
Section titled “Config”interface BrowserConfig { name: string headless?: boolean // default: true viewport?: { width: number // default: 1280 height: number // default: 720 }}Properties
Section titled “Properties”browserInterface
Section titled “browserInterface”browser.browserInterface: BrowserInterfaceThe WebSocket interface. Provides the WebSocket endpoint for connecting automation tools.
wsEndpoint
Section titled “wsEndpoint”browser.wsEndpoint: stringConvenience getter for the WebSocket URL. Returns an empty string before start() is called.
status
Section titled “status”Inherited from Entity. One of: "pending", "starting", "running", "stopping", "stopped", "error".
Lifecycle
Section titled “Lifecycle”start()
Section titled “start()”- Calls
chromium.launchServer()fromplaywright-core - Sets the WebSocket endpoint on the
BrowserInterface - Logs the WS URL for connection
If Chromium is not installed, prints a helpful error message directing you to run bunx playwright install chromium.
stop()
Section titled “stop()”Closes the browser server and releases all resources.
Examples
Section titled “Examples”Basic usage
Section titled “Basic usage”const browser = env.add( new Browser("chrome", { headless: true }));
// After env.up(), the WS endpoint is available:console.log(browser.wsEndpoint);// "ws://localhost:54321/abc123..."Connecting from Playwright
Section titled “Connecting from Playwright”import { chromium } from "playwright-core";
// Connect to the Sigil-managed browserconst browser = await chromium.connect(sigilBrowser.wsEndpoint);const page = await browser.newPage();await page.goto("http://localhost:3000");In a full-stack environment
Section titled “In a full-stack environment”import { Environment, Postgres, Service, Browser, APIInterface, BrowserInterface } from "sigil";
const env = new Environment("my-app");
const db = env.add(new Postgres("db", { database: "myapp" }));
env.add( new Service("backend", { command: ["node", "server.js"], env: { DATABASE_URL: db.connectionString }, readyCheck: { url: "http://localhost:8000/health" }, }, [new APIInterface(8000)]));
env.add( new Service("frontend", { command: ["bun", "run", "dev"], readyCheck: { url: "http://localhost:3000" }, }, [new BrowserInterface(3000)]));
// Browser starts last — all services are readyenv.add(new Browser("chrome", { headless: true }));
export default env;