WebAssembly: The Component Model
The Component Model lets small Wasm parts join into one app. A component is one reusable Wasm part.
Describe a greeter
WIT lists what a component offers.
interface greeter {
greet: func(name: string) -> string;
}Name the world
A world lists what one component needs and offers.
world hello {
export greet: func(name: string) -> string;
}Example
const B64 = "AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABags=";
(async () => {
const bytes = Uint8Array.from(atob(B64), c => c.charCodeAt(0));
const { instance } = await WebAssembly.instantiate(bytes, {});
console.log("2 + 3 =", instance.exports.add(2, 3));
})();Key points
- The Component Model is a plan for joining Wasm parts together.
- Use WIT to describe what a component offers.
- WIT is short for Wasm Interface Types.
- WASI 0.3 adds native async, streams, and futures.
- Components share types, so parts fit together cleanly.
- The loader below still loads one plain module today.
- Small parts join into one app under this model.
In this example, the code decodes the module bytes from B64 and instantiates the module. It calls add with 2 and 3 and logs the sum. Components are the future direction, but today the loader still loads one plain module.
Note
WASI 0.3 was ratified in 2026, and runtimes are still adding support.
Try it Yourself
Edit the code, then press Run.
Runs in your browser — the preview under the editor is the real result. Nothing is sent to a server. The code runner panel (right) does the same with more room.
Exercise
What does the Component Model do?