Docker images are 100MB+. WebAssembly packages are <1MB. Wasmer lets you run them like containers — with a package registry and everything.
What Is Wasmer?
Wasmer is a WebAssembly runtime that can run Wasm modules from any language. Plus, it has a package registry (WAPM/wasmer.io) like npm for Wasm.
# Install
curl https://get.wasmer.io -sSfL | sh
# Run a Wasm package
wasmer run python/python -- -c "print('Hello from Wasm!')"
wasmer run syrusakbary/cowsay "Hello WebAssembly!"
wasmer run php/php -- -r "echo 'Hello from PHP in Wasm!';"
Python, PHP, Ruby, Lua — running as WebAssembly. No native install needed.
Use as a Library
use wasmer::{Store, Module, Instance, Value};
fn main() -> anyhow::Result<()> {
let mut store = Store::default();
let module = Module::from_file(&store, "add.wasm")?;
let instance = Instance::new(&mut store, &module, &imports! {})?;
let add = instance.exports.get_function("add")?;
let result = add.call(&mut store, &[Value::I32(5), Value::I32(3)])?;
println!("5 + 3 = {}", result[0].unwrap_i32()); // 8
Ok(())
}
from wasmer import engine, Store, Module, Instance
store = Store(engine.JIT())
module = Module(store, open('add.wasm', 'rb').read())
instance = Instance(module)
result = instance.exports.add(5, 3)
print(f"5 + 3 = {result}") # 8
Wasmer Edge (Serverless)
# Deploy a Wasm app to the edge
wasmer deploy
# Running globally in <1ms cold start
Why Wasmer
- Universal — run Wasm from Rust, Python, Go, JavaScript, C, Ruby, PHP, Java
-
Package registry —
wasmer run author/packagelikenpx - Near-native speed — Cranelift/LLVM JIT compilation
- Sandboxed — Wasm modules can't access anything not explicitly allowed
- Tiny — packages are kilobytes, not megabytes
- Edge deploy — sub-millisecond cold starts
Building Wasm applications? Check out my developer tools or email spinov001@gmail.com.
Top comments (0)