⚡ Zig Guide LiveUnofficialbut fully verified
✓ Zig 0.18.0-dev.624+b7f2c6d8fWhat's newOn an older Zig?Blograylib-zig

WebAssembly

Zig treats wasm as an ordinary target. Thus Zig is one of the shortest paths from compiled code to a browser. These chapters show what a freestanding module is, and how to export functions to JavaScript. They show how to move strings and structs across a boundary that only passes numbers. They also show how to instantiate the module on a page, and how to build a WASI command. This site runs on the result.

  1. wasm is an ordinary target. Nothing about the language changes, and the same source builds for your machine and for a browser.
  2. The boundary only passes numbers. A string crosses as a pointer and a length into linear memory, and both sides must agree who owns the string.
  3. Freestanding means no libc, no WASI, and no allocator except one that you supply.

6 chapters.