DOM & Typed Events
Safe wrappers for Document, Window, Element,
CSSStyleDeclaration, Location, History,
Clipboard, and compile-time typed events via
Event.EventFor(name).
Zig 0.17.1 · WebAssembly · WASI
Type-safe Zig WebAssembly browser and WASI API wrappers around
zig-javascript-bridge
(zjb), with zero-global context-bound callbacks and host-side leak-checked mocks.
Safe wrappers for Document, Window, Element,
CSSStyleDeclaration, Location, History,
Clipboard, and compile-time typed events via
Event.EventFor(name).
Bind DOM listeners, animation frames, timers, and Promise
continuations directly to Zig struct pointers via boundFunction
and boundEventListenerTyped without global singletons.
Includes typed WebGL / WebGL2 bindings, Fetch &
Promise.Typed(T), browser file downloads (download.bytes),
and WASM-heap-safe IndexedDb wrappers.
Provides WebRTC, WebSocket, BroadcastChannel,
WebAssembly / JSPI helpers, and a pure-Zig WASI Snapshot Preview 1
runtime with in-memory, tar, and IndexedDB filesystems.
Add webapi to your build.zig.zon, wire the module and bindgen in build.zig, and build for wasm32-freestanding or wasm64-freestanding:
const webapi_pkg = @import("webapi");
const webapi_mod = b.dependency("webapi", .{}).module("webapi");
exe.root_module.addImport("webapi", webapi_mod);
const zjb_bindings = webapi_pkg.bindgen(b, .{
.wasm = exe.getEmittedBin(),
.basename = "zjb_bindings.js",
.classname = "Zjb",
.module_style = .es6,
.minify = optimize != .debug,
});
# Run host-side unit tests (with handle-leak detection)
zig build test
# Check Zig source formatting
zig build fmt -Dfmtcheck=true
# Emit API documentation, landing page, and example into zig-out/www/
zig build docs
Explore full signatures in the generated API reference or try live bindings in the
interactive demo: dom, Event, Promise,
WebGL, CanvasRenderingContext2D, Fetch, IndexedDb,
WebRTC, WebSocket, BroadcastChannel, Crypto,
WebAudio, Worker, CompressionStream, WebAssembly, and Wasi.
Built with zig-webapi: Tabletop 3D Virtual Physics Sandbox.