BrowserBox does not run your automation script inside the box. It places the browser inside the box and exposes a WebSocket endpoint; your script runs on the host and drives the browser remotely, so untrusted page JavaScript, downloads, and cookies never reach your machine.
Prerequisites
- A working BoxLite install (Python
boxliteor Node@boxlite-ai/boxlite) and a machine with hardware virtualization — see Installation. - Install the browser-driver client (used to connect from the host):
- Python:
pip install "playwright==1.58.0"(you do not needplaywright install; the browser lives in the sandbox) - Node:
npm install [email protected](an optional peer dependency of@boxlite-ai/boxlite) - The client version must match the Playwright Server version inside the sandbox (1.58.0). If you install an unpinned
pip install playwrightthat resolves to a newer version (for example 1.60.0),connect()receives428 Precondition Required, reportsPlaywright version mismatch, and fails. Pin1.58.0explicitly.
- Python:
- The first run pulls the image
mcr.microsoft.com/playwright:v1.58.0-jammy(several GB); this requires network access and takes a while.
Quick Example (happy path)
The snippet below starts an isolated Chromium from the host, navigates to example.com, and prints the title. It is ready to copy and run.@boxlite-ai/boxlite is an ESM-only package):
Two connection modes
BrowserBox offers two mutually exclusive ways to connect; a single instance can use only one of them:
A single instance cannot use bothConvenience helperplaywright_endpoint()andendpoint()— both bind host port 3000. If you need both modes, start a separateBrowserBoxfor each.
connect(): returns an already-connected Playwright Browser object directly (it uses Playwright Server mode internally), saving you the manual connect(ws) step.
Parameters & Returns
BrowserBoxOptions (Python, dataclass)
Construct as BrowserBox(options=BrowserBoxOptions(...)).
BrowserBox also accepts extra **kwargs that are passed through to the underlying SimpleBox (such as volumes, env, ports, name, auto_remove).
Node options (BrowserBoxOptions, object)
new BrowserBox({ ... }) inherits from SimpleBoxOptions (Omit<SimpleBoxOptions, "image" | "cpus" | "memoryMib"> — that is, image is removed, and cpus / memoryMib are re-declared as optional fields with browser defaults) and adds browser-specific fields:
Methods / return values
Image and version (fixed): the default image is
mcr.microsoft.com/playwright:v1.58.0-jammy, corresponding to Playwright 1.58.0. The client used to connect from the host must also be 1.58.0 (a mismatched client is rejected by the server; see Troubleshooting).

