A world is a WIT boundary for a component: it gathers the interfaces and functions the component imports from its host and exports for others to call. Think of it as the component’s declared external surface, similar to organizing related capabilities in a module or namespace. WIT keeps that surface high-level, so functions can use types such as strings rather than manual pointer-and-length memory handling. section 2.4
Imports state what the host must provide; exports state what the guest implements. This distinction makes responsibility explicit before implementation begins. A world can import a focused interface, such as a key-value store, while exporting a single entry-point function for running the guest. section 3.4.1
A SmartCMS application boundary
Define a kvstore interface with get and set, then make world app import that interface and export run. The host supplies key-value storage; the guest supplies run and returns output. This separates a reusable capability from the application’s own behavior. section 3.4.1
Worlds also define the interface shape used by WASI Preview 2 components. WASI 0.2 includes a command world for command-line-style applications and an HTTP proxy world for sending and receiving HTTP requests and responses, extending beyond WASI 0.1’s limited POSIX-like interface set. section 4.2
Listing 4.4 Output of wasm-tools component wit
package root:component {
world root {
import wasi:cli/environment@0.2.0;
import wasi:cli/exit@0.2.0;
import wasi:io/error@0.2.0;
import wasi:io/streams@0.2.0;
import wasi:cli/stdin@0.2.0;
import wasi:cli/stdout@0.2.0;
import wasi:cli/stderr@0.2.0;
import wasi:clocks/wall-clock@0.2.0;
import wasi:filesystem/types@0.2.0;
import wasi:filesystem/preopens@0.2.0;
export wasi:cli/run@0.2.0;
}
}
Inspect generated component WIT to see a root world list its WASI imports alongside its exported CLI run function. section 4.2.1
For a Rust CLI component, cargo component can generate much of the WIT setup. Build the component, then run wasm-tools component wit on the resulting .wasm file to inspect its root world and verify exactly which capabilities it imports and exports. section 4.2.1
