Skip to content

Browser automation

Browser automation is useful for agents, scraping, UI tests, and computer-use workflows. It is also high-risk because browsers handle cookies, downloads, credentials, and untrusted web content.

Use a Nix flake target that includes the browser runtime and automation library:

Terminal window
cargo run -- build --flake . --profile browser

The build runs through the builder VM. The browser runs later inside the runtime microVM.

Terminal window
cargo run -- up browserbox --flake . --profile browser
cargo run -- exec browserbox -- node /work/automation.js
  • Use a dedicated sandbox per browser session unless state reuse is intentional.
  • Keep credentials out of the base image.
  • Prefer short-lived secret references over copied cookie files.
  • Restrict egress to the target domains when possible.
  • Treat downloads as untrusted files.
  • Snapshot browser state only when you are comfortable retaining cookies, cache, local storage, and downloaded content.

Status: Planned lifecycle API.

browser = Sandbox.create(
image="nix:./flake#browser",
network=NetworkPolicy.deny_by_default().allow_https("example.com"),
)
try:
browser.files.write("/work/automation.py", script.encode())
result = browser.exec(["python", "/work/automation.py"])
finally:
browser.stop()