This page has content for both WASI P2 and WASI P3. Use the tabs below to switch between versions where they differ.
{{#tabs global="wasi-version" }}
{{#tab name="WASI P2" }}
Wasmtime is the reference implementation of the Component Model.
It supports running components that implement the wasi:cli/command world
and serving components that implement the wasi:http/proxy world.
Wasmtime can also invoke functions exported from a component.
{{#endtab }}
{{#tab name="WASI P3" }}
Wasmtime is the reference implementation of the Component Model. WASI P3 runtime support is available in Wasmtime 43 and later, which implements the WASI 0.3 ABI (async func, stream<T>, future<T>).
It supports running components that implement the wasi:cli/command world. Support for serving components in the wasi:http/service world and the new wasi:http/middleware world, which both imports and exports the HTTP handler interface, is in development. See the tracking issue for current status.
Wasmtime can also invoke functions exported from a component.
{{#endtab }}
{{#endtabs }}
To run a command component with Wasmtime, execute:
wasmtime run <path-to-wasm-file>If you are using an older version of
wasmtime, you may need to add the--wasm component-modelflag to specify that you are running a component rather than a core module.
By default, Wasmtime denies the component access to all system resources. For example, the component cannot access the file system or environment variables. See the Wasmtime guide for information on granting access, and for other Wasmtime features.
{{#tabs global="wasi-version" }}
{{#tab name="WASI P2" }}
You can execute components that implement the HTTP proxy world with the wasmtime serve subcommand.
The Wasmtime CLI supports serving these components as of v18.0.0.
To run a HTTP component with Wasmtime, execute:
wasmtime serve <path-to-wasm-file>Try out building and running HTTP components with one of these tutorials
-
Hello WASI HTTP tutorial - build and serve a simple Rust-based HTTP component
-
HTTP Auth Middleware tutorial - compose a HTTP authentication middleware component with a business logic component {{#endtab }} {{#tab name="WASI P3" }} Wasmtime 43 and later provide runtime support for the WASI P3 ABI. The
wasmtime servesubcommand currently targets thewasi:http/proxyworld from WASI P2; support for serving components in the WASI P3wasi:http/serviceandwasi:http/middlewareworlds is in progress. See the tracking issue for current status.
For an overview of the WASI P3 HTTP interfaces, see WASI 0.3 on WASI.dev. {{#endtab }} {{#endtabs }}
As of Wasmtime Version 33.0.0, there is support for invoking components with custom exports.
As an example, if your component exports a function add which takes two numeric arguments, you can make use of this feature with the following command.
wasmtime run --invoke 'add(1, 2)' <path-to-wasm-file>Make sure to wrap your invocation in single quotes and to include parentheses, even if your function doesn't take any arguments. For a full list of ways to represent the various WIT types when passing arguments to your exported function, visit the WAVE repository.