# webframe Run a web page like a program. webframe loads a URL in a hidden webview, keeps it running at full speed, and connects the page to your terminal: the `console` goes to stdout, exceptions go to stderr, and you can evaluate JavaScript in the page from stdin. ``` $ webframe examples/hello.html Hello, world! ``` It uses the webview the OS already has (WebKit on macOS, WebKitGTK on Linux, WebView2 on Windows) through [glaze](https://github.com/progrium/glaze), so it is a small single binary with no bundled browser and, on most platforms, no cgo. ## Uses - Run browser-only code (WASM, WebGPU, Web Audio, DOM libraries) from scripts, CI, or cron without a full browser automation stack. - Keep a page running in the background as a long-lived process, like a daemon or worker. - Poke at a live page from a REPL with `-c`. - Run a single-page app or emulator headless, such as [v86](examples/v86.html), and talk to it over stdio or WebSocket. - Use it as a library for cross-platform isolation ## Install Download a zip for your platform from the releases, or build from source with Go 1.27+: ``` go install tractor.dev/webframe/cmd/webframe@latest ``` Runtime requirements: | Platform | Needs | |---|---| | macOS | Nothing | | Windows | Edge WebView2 Runtime (preinstalled on Windows 10/11) | | Linux (glibc) | WebKitGTK 4.1 or 6.0, plus a display or Xvfb | | Linux (musl, Alpine) | `apk add webkit2gtk-4.1 xvfb`, and the `linux-musl` build | On Linux, if neither `DISPLAY` nor `WAYLAND_DISPLAY` is set, webframe starts its own private Xvfb and shuts it down when it exits. If you run it under `xvfb-run` or in a desktop session, it uses that display instead. Debian/Ubuntu: `apt install libwebkit2gtk-4.1-0 xvfb` ## Usage ``` webframe [-s|-S] [-e] [-c] [-d] [-v] [-w [WIDTHxHEIGHT]] ``` The argument is required. It can be a URL or a path to a local file. Use `about:blank` for an empty page. | Flag | | |---|---| | `-c` | Console: evaluate each line of stdin in the page and print the result | | `-e` | Exit with status 1 on the first exception | | `-s` | Silence exceptions | | `-S` | Silence all output (stdout and stderr, including native libraries) | | `-w [WxH]` | Show a window, optionally sized, e.g. `-w 1024x768` | | `-d` | Enable the web inspector | | `-v` | Print version | ### Output `console.log` prints to stdout as-is. Other console methods are prefixed: ``` hello 1 {"a":[1,2]} null undefined [warn] careful [error] Error: boom global code@file:///tmp/page.html:4:49 ``` Arguments are formatted much like Node: strings print raw, other values as JSON, with handling for cycles (`[Circular]`), errors (with stacks), functions, `undefined`, symbols, bigints and DOM nodes. Output keeps the page's order, even in fast bursts. Exceptions print to stderr with as much detail as the engine gives: - uncaught errors - unhandled promise rejections - resources that fail to load, like `` and `