LinuxCommandLibrary

wasmtime

TLDR

Run a WebAssembly file

$ wasmtime [program.wasm]
copy
Run with directory access
$ wasmtime --dir [/path/to/dir] [program.wasm]
copy
Invoke a specific function
$ wasmtime run --invoke '[add(1, 2)]' [program.wasm]
copy
Run a WASI HTTP server
$ wasmtime serve [component.wasm]
copy
Compile to native ahead-of-time
$ wasmtime compile [program.wasm] -o [program.cwasm]
copy
Run compiled module
$ wasmtime run [program.cwasm]
copy
Enable WASI features
$ wasmtime -S inherit-env [program.wasm]
copy

SYNOPSIS

wasmtime [options] [command] [wasm-file] [args...]

DESCRIPTION

wasmtime is a standalone WebAssembly runtime from the Bytecode Alliance. It executes WebAssembly modules and components outside the browser, supporting WASI (WebAssembly System Interface) for system access.
The runtime can execute both binary (.wasm) and text (.wat) WebAssembly files. For performance-critical applications, modules can be ahead-of-time compiled to native code using the compile subcommand.
By default, Wasmtime sandboxes modules with no access to system resources. Access to files, environment, and network must be explicitly granted through command-line options.
The serve subcommand runs WebAssembly components implementing the wasi:http/proxy interface as HTTP servers.

PARAMETERS

--dir path

Grant access to host directory.
--env key=value
Set environment variable.
--invoke expr
Invoke specific exported function.
-O, --optimize options
Optimization settings.
-C, --codegen options
Code generation settings.
-D, --debug options
Debug settings.
-W, --wasm options
WebAssembly semantics settings.
-S, --wasi options
WASI configuration (inherit-env, inherit-network).
--config file
Load settings from TOML file.
-h, --help
Display help.
-V, --version
Display version.

COMMANDS

run: Execute WebAssembly module (default).
serve: Run component as WASI HTTP server.
compile: AOT compile to native code.
config: Manage Wasmtime configuration.
wast: Execute WebAssembly spec tests.

CAVEATS

WASI is not fully POSIX-compatible. Some system calls may not be available. Ahead-of-time compiled modules are platform-specific. Component Model support is evolving.

HISTORY

Wasmtime was developed by the Bytecode Alliance, a nonprofit organization including Mozilla, Fastly, Intel, and Red Hat. It serves as a reference implementation for WebAssembly outside the browser and drives development of WASI and the Component Model standards.

SEE ALSO

Copied to clipboard