WebAssembly (Wasm)
WebAssembly โ (abbreviated Wasm) allows you to compile languages like Rust, Go, or C to a binary format that can run in a wide variety of environments, including web browsers โ, Cloudflare Workers, and other WebAssembly runtimes.
On Workers and in Cloudflare Pages Functions โ, you can use WebAssembly to:
- Execute code written in a language other than JavaScript, via
WebAssembly.instantiate()
. - Write an entire Cloudflare Worker in Rust, using bindings that make Workers' JavaScript APIs available directly from your Rust code.
Most programming languages can be compiled to Wasm, although support varies across languages and compilers. Guides are available for the following languages:
WebAssembly is a rapidly evolving set of standards, with many proposed APIs โ which are in various stages of development. In general, Workers supports the same set of features that are available in Google Chrome.
SIMD is supported on Workers. For more information on using SIMD in WebAssembly, refer to Fast, parallel applications with WebAssembly SIMD โ.
Threading is not possible in Workers. Each Worker runs in a single thread, and the Web Worker โ API is not supported.
Compiling to WebAssembly often requires including additional runtime dependencies. As a result, Workers that use WebAssembly are typically larger than an equivalent Worker written in JavaScript. The larger your Worker is, the longer it may take your Worker to start. Refer to Worker startup time โ for more information. We recommend using tools like wasm-opt
โ to optimize the size of your Wasm binary.
The WebAssembly System Interface โ (abbreviated WASI) is a modular system interface for WebAssembly that standardizes a set of underlying system calls for networking, file system access, and more. Applications can depend on the WebAssembly System Interface to behave identically across host environments and operating systems.
WASI is an earlier and more rapidly evolving set of standards than Wasm. WASI support is experimental on Cloudflare Workers, with only some syscalls implemented. Refer to our open source implementation of WASI โ, and blog post about WASI on Workers โ demonstrating its use.