English for the WebAssembly Component Model

Learn the vocabulary of the WebAssembly Component Model: WIT, worlds, interfaces, WASI preview2, composition, Wasmtime, Spin, canonical ABI, guest components, and host embedding.

The WebAssembly Component Model is one of the most significant developments in server-side WebAssembly, and it comes with a rich and specific vocabulary. If you are contributing to WASM tooling, building serverless functions with Spin, or working with Wasmtime, you need to understand the terminology used in specifications, documentation, and community discussions. This post covers the key vocabulary you will encounter.

Key Vocabulary

WIT (WebAssembly Interface Types) — A language used to define the interfaces between WebAssembly components. WIT files describe the types, functions, and resources that components can import or export. Example: “The WIT file defines the interface that the host must implement for the component to call into.”

World — In WIT, a world defines the complete set of imports and exports for a component. It describes what the component needs from the host and what it offers to callers. Example: “The component targets the wasi:http/proxy world, which means it expects the host to provide HTTP request handling.”

Interface — A named collection of types and functions in WIT, similar to an interface in other languages. A world is composed of interfaces. Example: “The wasi:filesystem/types interface defines the types used for file I/O operations.”

Component — The top-level unit of composition in the WebAssembly Component Model. A component packages a WebAssembly module together with its interface definitions, allowing it to be composed with other components. Example: “We distribute our image processing logic as a standalone component that can be composed into any host application.”

WASI (WebAssembly System Interface) Preview 2 — The second major revision of WASI, built on top of the Component Model. It replaces WASI Preview 1’s POSIX-like API with a component-based interface. Example: “We’re migrating from WASI Preview 1 to Preview 2 to take advantage of the typed interfaces and composition capabilities.”

Composition — The process of linking multiple components together so that one component’s exports satisfy another’s imports. Example: “Component composition lets us wire the logging component’s output directly into the observability component without modifying either.”

Host embedding — The environment that loads and runs WebAssembly components. The host provides the imports the component declared in its world. Example: “Wasmtime acts as the host embedding — it provides the WASI interfaces and runs the component.”

Wasmtime — A production-grade WebAssembly runtime developed by the Bytecode Alliance, with full support for the Component Model. Example: “We run our serverless functions using Wasmtime with the wasmtime-wasi crate providing the host-side WASI implementation.”

Spin framework — A developer framework by Fermyon for building and deploying server-side WebAssembly applications. Spin handles host embedding, routing, and runtime concerns so developers can focus on component logic. Example: “We wrote our API handler as a Spin component using the Rust SDK — Spin handles the HTTP routing and WASI runtime.”

Guest component — A component that runs inside a host embedding. The guest consumes imports provided by the host and produces exports consumed by the host or other components. Example: “The guest component implements the handle function that Spin invokes for each incoming HTTP request.”

Canonical ABI — The encoding specification that defines how WebAssembly Interface Types are lowered to and lifted from the core WebAssembly type system (i32, i64, f32, f64, memory). Example: “When you call a function across a component boundary, the Canonical ABI handles encoding the string argument as a pointer-length pair in linear memory.”

How to Use This in Practice

When reading Component Model documentation, the relationship between key terms follows this hierarchy: a world contains interfaces, which contain functions and types. A component targets a world — it declares what it exports and what it imports. The host embedding provides the imports; composition connects multiple components’ imports and exports.

In practical discussions: “Does this component target WASI Preview 2 or Preview 1?” tells you whether the component uses the new typed interface model or the older POSIX-style API. “Is this a guest component or a host-side implementation?” clarifies whether you are writing application logic or embedding runtime infrastructure.

The Canonical ABI is usually discussed when debugging cross-component calls: “The string is being encoded using the Canonical ABI, so it arrives as a pointer and length pair — make sure your host implementation reads it correctly from linear memory.”

Example Conversation

Developer (Ivan): “I’m trying to compose two WASM components but the types aren’t matching at the boundary.”

Runtime Engineer: “Are both components targeting the same WIT world, or are you trying to connect interfaces from different worlds?”

Ivan: “They’re separate worlds. One exports wasi:http/handler and the other expects a custom logging interface.”

Runtime Engineer: “You’ll need an adapter component to bridge them. The Canonical ABI will handle the type encoding automatically once the interface types match — the issue is that the worlds don’t share a common interface definition. Define a shared interface in a common WIT package and have both components import it.”

Practice Tips

  1. Read a WIT file: The WASI proposals repository on GitHub (github.com/WebAssembly/WASI) contains WIT files for standard interfaces like wasi:filesystem, wasi:http, and wasi:clocks. Read one file and identify the world, the interfaces, and a few type definitions. Try to describe what the component that targets this world would need to implement.

  2. Trace a component composition example: The Bytecode Alliance’s wasm-tools repository has composition examples. Find a simple two-component composition and describe in English what each component imports and exports, and how the composition wires them together.

  3. Explain the Canonical ABI to yourself: In your own words, write a sentence explaining why the Canonical ABI is necessary. Hint: think about what happens when a high-level type like a string needs to cross the boundary between two WebAssembly modules that only understand numeric types.