Wasmtime
A fast and production-ready WebAssembly runtime to securely execute any code
Wasmtime allows developers to run untrused, and non-portable code. Compiling code to WebAssembly & WASI allows Wasmtime to execute your code in a secure sandbox on your device or embedded within your application. Get started with Wasmtime below:
Installing Wasmtime
It looks like you’re running macOS or Linux. To download and install Wasmtime, run the following in your terminal, then follow the on-screen instructions.
curl https://wasmtime.dev/install.sh -sSf | bash
Alternatively, you can also download releases for all supported platforms from the Wasmtime GitHub page.
Wasmtime CLI Usage
wasmtime [Your Version Here]
Wasmtime WebAssembly Runtime
USAGE:
wasmtime <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
compile Compiles a WebAssembly module
config Controls Wasmtime configuration settings
help Prints this message or the help of the given subcommand(s)
run Runs a WebAssembly module
settings Displays available Cranelift settings for a target
wasm2obj Translates a WebAssembly module to native object file
wast Runs a WebAssembly test script file
If a subcommand is not provided, the `run` subcommand will be used.
Usage examples:
Running a WebAssembly module with a start function:
wasmtime example.wasm
Passing command line arguments to a WebAssembly module:
wasmtime example.wasm arg1 arg2 arg3
Invoking a specific function (e.g. `add`) in a WebAssembly module:
wasmtime example.wasm --invoke add 1 2
Embedding Wasmtime in Your Application
Wasmtime implements the standards-track Wasm-C-API.
The Bytecode Alliance also hosts Wasmtime embedding APIs for a number of languages:
See our documentation on language embeddings for details on how to get started with these.
In addition, embedding APIs for other languages are maintained outside the Bytecode Alliance:
- Java (two options: kawamuray/wasmtime-java or bluejekyll/wasmtime-java)
- Perl
- Zig
- Ruby
Targeting Wasmtime
We're maintaining WASI toolchains for Rust and C/C++. For an introduction to those, please see our WASI tutorial, which has sections on C and Rust.
See our collection of examples for some examples of content to run in, and ways to use Wasmtime.
For more information on WASI, see the WASI homepage.
Building Wasmtime
System requirements
Building Wasmtime requires a recent version of the Rust compiler and toolchain, and a C++ toolchain released after 2007.
Downloading and building the sources
With those requirements in place, you can download and build the Wasmtime source:
git clone --recurse-submodules \
https://github.com/bytecodealliance/wasmtime.git
cd wasmtime
cargo build --release
License
Wasmtime is licensed under Apache 2.0 with an LLVM Exception.
It's Wasmtime! 😎