Skip to content

About

A pretty tiny browser you can embed anywhere.

Topics

Resources

Contributing

Stars

318 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,805 Commits

Folders and files

Repository files navigation

tinybrowser

Sponsor Ko-fi

A pretty tiny browser you can embed anywhere.

It speaks the Chrome DevTools Protocol and W3C WebDriver (Classic and BiDi), so Playwright and Selenium can drive it. It also compiles to WebAssembly, which is how the live demo runs inside your browser.

tinybrowser is experimental:

  • Not every Web API is implemented yet. The WPT page shows current coverage.
  • JavaScript runs on QuickJS-ng with no JIT, so JS-heavy pages are slower than on V8.
  • There is no out-of-process iframe isolation yet, and OS sandboxing is not battle-tested.
  • Rendering is headless, one-shot screenshots only.

Full documentation: https://tinybrowser.ericc.ch/#documentation

Install

WebAssembly SDK:

npm install @tinybrowser/wasm
# or
bun add @tinybrowser/wasm

macOS and Linux:

curl -fsSL https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.sh | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.ps1 | iex

npm:

npx tinybrowser --help
npx tinybrowser daemon start

# or install globally
npm install -g tinybrowser

Archives for every platform are on GitHub Releases.

WebAssembly

@tinybrowser/wasm ships as a WASI Preview 2 component. You pass the component, the module loader, the WASI shims, and the transport. The Node entry needs Node 22 or later; Bun, browsers, and Workers use their own loaders.

import { createTinyBrowser } from "@tinybrowser/wasm"
import { instantiate } from "@tinybrowser/wasm/instantiate"
import {
  createNodeModuleLoader,
  createNodeTransport,
  createNodeWasi,
} from "@tinybrowser/wasm/node"

const browser = await createTinyBrowser({
  instantiate,
  module: createNodeModuleLoader(import.meta.resolve("@tinybrowser/wasm/core.wasm")),
  wasi: createNodeWasi(),
  transport: createNodeTransport(),
})

const tab = browser.createContext().openTab()
const result = await tab.goto("https://example.com/", { waitUntil: "networkidle" })

console.log(result.ok, result.reason, tab.title())
browser.dispose()

The waitUntil modes and the full API are in packages/wasm/README.md and on the website.

Daemon

Start the daemon. It prints its endpoint as JSON:

tinybrowser daemon start
# {"profile":"default","pid":12345,"host":"127.0.0.1","port":41234,"url":"http://127.0.0.1:41234"}

tinybrowser daemon status
tinybrowser daemon stop

To connect Playwright over CDP, pass the printed URL to chromium.connectOverCDP:

import { chromium } from "playwright-core"

const browser = await chromium.connectOverCDP("http://127.0.0.1:41234")
const page = browser.contexts()[0].pages()[0]
await page.goto("https://example.com")
console.log(await page.title())

For WebDriver Classic, send POST /session to the same port. For BiDi, connect to ws://127.0.0.1:<port>/session.

Source reference

Need File
Exact WIT interface: types, resources, host imports crates/wasm/wit/browser.wit
Wasm driver internals: waitUntil, pump budgets, wakeups, public types packages/wasm/src/driver.ts, types.ts
Browser loader, Workers loader, hop proxy, storage state schemas packages/wasm/README.md
Every CLI subcommand, flag, environment variable, and path src/cli.rs or tinybrowser --help
npm CLI platform packages, target mapping, SHA-256 fallback, cache packages/cli/README.md
Hosted Executor MCP app: Cloudflare Workers, SQLite persistence apps/executor/README.md
Web Platform Tests coverage and failing tests https://tinybrowser.ericc.ch/wpt

Building from source

git clone https://github.com/tinybrowser-dev/tinybrowser
cd tinybrowser
git submodule update --init third_party/blitz third_party/rquickjs third_party/html5ever
git -C third_party/rquickjs submodule update --init sys/quickjs
nix develop          # or rustup; rust-toolchain.toml selects the pinned nightly
cargo build --release

The release profile needs the pinned nightly (build-std, force-unwind-tables=no). The WPT harness also needs third_party/wpt; see tools/wpt/README.md. Before you change engine code, read CONTRIBUTING.md, docs/owners.md, and docs/adr/.

License and credits

MIT licensed (LICENSE). Third-party notices are in NOTICE, and acknowledgements are in CREDITS.md.

About

A pretty tiny browser you can embed anywhere.

Topics

Resources

Contributing

Stars

318 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages