liveBook · Manning

WASI

As explained in Server-Side WebAssembly

WASI 1.0 is a planned stable version of the WebAssembly System Interface intended to begin long-term stability guarantees.

WASI (WebAssembly System Interface) is the portable boundary between a Wasm program and its host environment. A Wasm runtime implements its APIs so a guest can use selected system capabilities—such as standard output, environment variables, files, sockets, or HTTP—without assuming a particular operating system. The host, rather than the guest binary, supplies those capabilities. section 1.0 section 4.1

This makes a Wasm runtime plus WASI analogous to the layer a Docker engine provides between an application and the host OS. Unlike a traditional container, a Wasm distribution packages application logic rather than a full userspace environment; portability depends on runtimes implementing the standardized interface. section 7.1 section 1.2.5

Figure 4.5 Comparison of WASI 0.1 (a more POSIX-like interface) to WASI 0.2 that defines higher-level interfaces
A screenshot of a computer

AI-generated content may be incorrect.

Compare the POSIX-like foundation of WASI 0.1 with the higher-level, component-oriented interfaces introduced by WASI 0.2. section 4.2

WASI 0.1, also called Preview 1, began as a highly portable POSIX-like subset for Wasm modules. WASI 0.2, or Preview 2, adopts the component model and WIT-defined worlds, enabling broader interfaces. It defines the wasi:cli/command world for command-line programs and wasi:http/proxy for HTTP request and response handling. section 4.2 section 4.7

Give a component controlled file access

A SmartCMS story component reads stories.txt, chooses a line, and returns it to a composed key-value component. The host creates a WASI context, preopens the current directory with read-only permissions, and links WASI into Wasmtime. The guest can read only the capability the host grants, rather than receiving unrestricted OS access. section 4.6 section 4.7

A practical WASI workflow is:

  • Create and build a command component with cargo component; current tooling may compile through wasm32-wasip1 and adapt the result to WASI 0.2. section 4.2.1
  • Inspect the produced component’s WIT imports and exports with wasm-tools component wit when verifying its interface. section 4.2.1 section 4.7
  • Run a command component with Wasmtime, or embed it in a host that configures its WASI context and linker. section 4.2.1 section 4.1
  • Compose compatible components with wac plug to connect imports and exports, while granting only the WASI capabilities each composed application needs. section 4.7

WASI is expanding from system-style calls into a collection of standard interfaces for application work, including HTTP, SQL, machine learning, key-value storage, messaging, and more. Many proposed interfaces remain under development rather than fully standardized. WASI 0.3 is planned to add native asynchronous futures and streams; it is intended to lay groundwork for WASI 1.0’s long-term stability guarantees. section 5.1 section 9.3 section 9.5

How Server-Side WebAssembly covers it

How deep it goes
Explains capability setup, component worlds, version differences, inspection, and composition, while deferring full standardization of many proposed interfaces.
Examples
Uses Hello World standard output, a WASI command component, and SmartCMS story-file access composed with a key-value store.
What it assumes
Teaches WASI from browser-versus-host execution and builds on Wasm components, WIT, Rust tooling, and host concepts.
What you can do after
Operate/configure it by linking WASI in a host, granting stdout or read-only directories, inspecting WIT, and running components with Wasmtime.
How it connects
Connects WebAssembly, Wasmtime, the Component Model, WIT, POSIX, Docker containers, serverless, and HTTP.

Also explained in

Compare how 3 books explain WASI →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.