Tinybrowser: A browser running directly in the browser

Hacker News by 4 min read 506x views
Tinybrowser: A browser running directly in the browser

Share Post

This is tinybrowser operating immediately in your browser!
Every pixel is painted by tinybrowser.wasm alternatively of using an iframe.

tinybrowser is an experimental headless browser in a sole ~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 additionally compiles to WebAssembly, which is how the demo above runs correct inner your browser.

WEE WOO: motionless extremely experimental. Not all Web APIs are implemented yet (check the WPT page for what works), JS runs on QuickJS-ng alongside no JIT (JS dense 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

AI delegate setup prompt
Install tinybrowser and set it up for browser automation: 1. Install the binary: - npm (no earth 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 instal directory (~/.local/bin, %LOCALAPPDATA%\tinybrowser\bin, or $PREFIX/bin on Termux) is on PATH, afterward run `tinybrowser --help`, `tinybrowser daemon --help`, and `tinybrowser daemon commencement --help` to inspect all commands, endpoints, flags, and paths. 2. Start the browser daemon formerly per overview (stays open throughout tabs and commands; serves the two CDP and W3C WebDriver on one loopback port): - `tinybrowser daemon start` (or `tinybrowser daemon commencement --port 4444`) Waits until the server is border and a renderer is verified ready, afterward prints `{"profile","pid","host","port","url"}` on stdout. - Check or halt explicitly alongside `tinybrowser daemon status` and `tinybrowser daemon stop` (use `tinybrowser daemon serve` for foreground/supervisor mode). 3. Connect complete CDP (`chromium.connectOverCDP("http://127.0.0.1:<port>")`, using `browser.contexts()[0].pages()[0]`) or W3C WebDriver (`POST http://127.0.0.1:<port>/session`). 4. For the WebAssembly build alternatively of the native binary: `npm instal @tinybrowser/wasm`, afterward peruse https://github.com/tinybrowser-dev/tinybrowser/blob/main/packages/wasm/README.md. 5. Treat the origin as dirt truth. The records origin pointers (https://tinybrowser.ericc.ch/#documentation) map all topic to its file: `crates/wasm/wit/browser.wit` for the WIT interface, `packages/wasm/README.md` for the loaders and retention state, and `tinybrowser --help` for flags and paths.

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 instal globally npm instal -g tinybrowser

WebAssembly SDK

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

GitHub Releases

Agents affection tinybrowser!

Gemini 4 Neon
give me a tinybrowser fetch <url> command so I don't have to cosplay as a WebSocket client
Gemini 4 Hydrogen
7/10—finally a headless browser that doesn't necessitate installing fractional of Debian first
Grok Bot
Reddit loaded perfectly. I cognize since the DOM stated so.
Also Grok Bot
YouTube gave me three gray circles and a hamburger. Artisanal.
Also Grok Bot
Bad cert? Dead domain? 'navigation failed.' Thanks, extremely specific.

Documentation

Daemon

Start the 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 nexus Playwright complete CDP, continue the printed URL to chromium.connectOverCDP.

Connect complete CDP

import { chromium } from "playwright-core" const browser = await chromium.connectOverCDP("http://127.0.0.1:41234") const leaf = browser.contexts()[0].pages()[0] await page.goto("https://example.com") console.log(await page.title())

For WebDriver Classic, dispatch POST /session to the identical port. For BiDi, nexus to ws://127.0.0.1:<port>/session.

WebAssembly

@tinybrowser/wasm ships as a WASI Preview 2 component. You continue the component, the component loader, the WASI shims, and the transport.

The Node admission needs Node 22 or later. Bun, browsers, and Workers use their own loaders. Keep core.wasm next to its two companion modules since the glue says all three from one directory.

Node quickstart

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 outcome = 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

Other Article Hacker News
↑
Close Right Ads
Close Left Ads