首页 > AI前沿 > Tinybrowser: A browser running directly in the browser

Tinybrowser: A browser running directly in the browser

Hacker News 2026-12-05 09:48 15 阅读 查看原文
tinybrowser is an experimental headless browser in a single ~19 MB Rust binary. Currently passing 70.4% of Web Platform Tests subtests ( 62.5% of files). It speaks Chrome DevTools Protocol and W3C WebDriver (Classic + BiDi), so Playwright and Selenium *should* work. It also compiles to WebAssembly, which is how the demo above runs right inside your browser. WEE WOO: still very experimental. Not all Web APIs are implemented yet (check the WPT page for what works), JS runs on QuickJS-ng with no JIT (JS heavy pages are slower than V8), there's no out-of-process iframe isolation yet, OS sandboxing isn't battle-tested, and rendering is headless one-shot PNGs only. Install Install tinybrowser and set it up for browser automation: 1. Install the binary: - npm (no global install): npx tinybrowser --help - macOS / 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 - Ensure the install directory (~/.local/bin, %LOCALAPPDATA%\tinybrowser\bin, or $PREFIX/bin on Termux) is on PATH, then run `tinybrowser --help`, `tinybrowser daemon --help`, and `tinybrowser daemon start --help` to inspect all commands, endpoints, flags, and paths. 2. Start the browser daemon once per profile (stays open across tabs and commands; serves both CDP and W3C WebDriver on one loopback port): - `tinybrowser daemon start` (or `tinybrowser daemon start --port 4444`) Waits until the server is bound and a renderer is verified ready, then prints `{"profile","pid","host","port","url"}` on stdout. - Check or stop explicitly with `tinybrowser daemon status` and `tinybrowser daemon stop` (use `tinybrowser daemon serve` for foreground/supervisor mode). 3. Connect over CDP (`chromium.connectOverCDP("http://127.0.0.1: ")`, using `browser.contexts()[0].pages()[0]`) or W3C WebDriver (`POST http://127.0.0.1: /session`). 4. For the WebAssembly build instead of the native binary: `npm install @tinybrowser/wasm`, then read https://github.com/tinybrowser-dev/tinybrowser/blob/main/packages/wasm/README.md. 5. Treat the source as ground truth. The documentation source pointers (https://tinybrowser.ericc.ch/#documentation) map every topic to its file: `crates/wasm/wit/browser.wit` for the WIT interface, `packages/wasm/README.md` for the loaders and storage state, and `tinybrowser --help` for flags and paths. curl -fsSL https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.sh | sh irm https://raw.githubusercontent.com/tinybrowser-dev/tinybrowser/main/install.ps1 | iex npx tinybrowser --help npx tinybrowser daemon start # or install globally npm install -g tinybrowser npm install @tinybrowser/wasm # or bun add @tinybrowser/wasm GitHub Releases Agents love tinybrowser! give me a tinybrowser fetch command so I don't have to cosplay as a WebSocket client 7/10—finally a headless browser that doesn't require installing half of Debian first Reddit loaded perfectly. I know because the DOM said so. YouTube gave me three gray circles and a hamburger. Artisanal. Bad cert? Dead domain? 'navigation failed.' Thanks, very specific. Documentation Daemon 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: /session. 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. Keep core.wasm next to its two companion modules because the glue reads all three from one directory. 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() waitUntil modes goto, mount, back, forward, and reload default to load. restoreTabState and waitForIdle default to quiet. API Source reference