Wasmer is flashy. Wasmtime is industrial. Backed by Mozilla, Fastly, Intel, and Microsoft — Wasmtime is the WASI reference implementation.
What Is Wasmtime?
Wasmtime is a fast, secure, production-grade WebAssembly runtime from the Bytecode Alliance. It's the reference implementation for WASI (WebAssembly System Interface).
# Install
curl https://wasmtime.dev/install.sh -sSf | bash
# Run a Wasm module
wasmtime hello.wasm
Embed in Your Application
use wasmtime::*;
fn main() -> anyhow::Result<()> {
let engine = Engine::default();
let module = Module::from_file(&engine, "add.wasm")?;
let mut store = Store::new(&engine, ());
let instance = Instance::new(&mut store, &module, &[])?;
let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?;
let result = add.call(&mut store, (5, 3))?;
println!("5 + 3 = {result}"); // 8
Ok(())
}
from wasmtime import Store, Module, Instance
store = Store()
module = Module.from_file(store.engine, "add.wasm")
instance = Instance(store, module, [])
add = instance.exports(store)["add"]
result = add(store, 5, 3)
print(f"5 + 3 = {result}")
WASI: System Interface
// Wasm module can access files, env vars, clocks — with explicit permissions
let wasi = WasiCtxBuilder::new()
.inherit_stdout()
.preopened_dir("./data", "data")? // Only this directory
.env("API_KEY", "secret")? // Only this env var
.build();
Component Model
# Compose Wasm components
wasm-tools compose auth.wasm -d database.wasm -o app.wasm
# Two modules linked together, sharing typed interfaces
Why Wasmtime
- Production-grade — used by Fastly, Shopify, SingleStore in production
- WASI reference — the standard others follow
- Cranelift JIT — near-native execution speed
- Fuel metering — limit computation (prevent infinite loops)
- Component Model — typed interfaces between Wasm modules
- Embeddings — Rust, C, Python, Go, .NET, Ruby
Building Wasm-powered systems? Check out my developer tools or email spinov001@gmail.com.
Top comments (0)