Skip to content

zerobuf

Structured data in WebAssembly.Memory. Works in any JS runtime — browser, Worker, Node, Deno, Bun.

zerobuf defines a binary layout (tagged values, strings, arrays, objects) over WebAssembly.Memory and gives you JS accessor objects that read/write directly — no serialization, no copies.

You can use it with a WASM module (Zig, Rust, C, etc.) for shared-memory interop, or standalone with just new WebAssembly.Memory() as a structured binary buffer.

import { zerobuf } from "zerobuf";
// Standalone — no WASM module needed
const buf = zerobuf(new WebAssembly.Memory({ initial: 1 }));
const point = buf.create({ x: 1.0, y: 2.0, label: "origin" });
point.x = 3.14; // writes to memory
console.log(point.x); // reads from memory
// Or with WASM — both sides share the same memory
const buf2 = zerobuf(wasm.exports.memory);

Anywhere WebAssembly.Memory is available:

  • Browser (main thread, Web Workers, Service Workers)
  • Cloudflare Workers and Durable Objects
  • Node.js, Deno, Bun

zerobuf architecture

  • JS library with defineProperty accessors (V8-optimized reads, ~8M ops/sec)
  • Zig library with matching binary layout and C ABI exports
  • Dynamic objects: push, extend, grow, add properties
  • All types: null, bool, i32, f64, bigint, string, bytes, array, object
  • Schema mode: fixed-layout objects with precomputed offsets, no Proxy
  • Arena save/restore for per-request cleanup in long-lived processes