Skip to content

WASI & Beyond the Browser

WebAssembly was designed for the browser — but its properties (safe sandboxing, near-native speed, and language-agnostic portability) make it equally valuable on servers, edge nodes, embedded devices, and plugin systems. The key that unlocks all of these environments is WASI — the WebAssembly System Interface.

In the browser, the JavaScript engine is the host. It provides the runtime environment, handles memory, and exposes browser APIs. Outside the browser there is no JavaScript engine, no DOM, no fetch. A Wasm module that wants to read a file, write to stdout, or open a network socket needs a different host to supply those capabilities.

WASI is the standardised answer: a set of POSIX-like system-call definitions expressed as Wasm imports. Any runtime that implements WASI can run the same .wasm binary — on Linux, macOS, Windows, or a tiny microcontroller.

flowchart LR
  H["Host\n(OS / Edge Platform)"]
  R["WASI Runtime\n(wasmtime / wasmer)"]
  M["Wasm Module\n(.wasm binary)"]
  H -->|"grants capabilities\n(dirs, sockets, env vars)"| R
  R -->|"exposes WASI imports\n(fd_write, path_open …)"| M
  M -->|"calls imports to\nread/write/execute"| R
Host → WASI runtime → Wasm module

The diagram shows the three-layer model:

  1. Host — the operating system or cloud platform. It decides which resources (directories, sockets, environment variables) the runtime may pass through.
  2. WASI Runtime — a standalone executable such as wasmtime or wasmer. It implements the WASI spec as Wasm import functions and enforces capability grants.
  3. Wasm Module — the compiled binary. It imports WASI functions the same way it would import any other Wasm import. It never calls the OS directly.
#LessonWhat you will learn
1This overviewThe why and the architecture
2WASI Deep DiveCapability security, Preview 1 vs 2, compiling Rust to WASI
3wasmtime & wasmerRunning and embedding Wasm binaries with real runtimes
4Component Model, SIMD & ThreadsWIT interfaces, SIMD v128, and threads overview
5Use Cases & When to Use WasmPlugins, edge, sandboxing, portable CLIs, and trade-offs
What does WASI stand for?
Which layer enforces capability grants in the host–runtime–module model?
Why can a WASI-compiled .wasm binary run on multiple platforms without recompilation?