Skip to content

WebAssembly Component Rules

Build production-ready WebAssembly components with Bazel

The WebAssembly Component Model is a revolutionary approach to building portable, secure, and composable software. Think of it as “microservices for WebAssembly” - you can build small, focused components in any language and connect them together like LEGO blocks.

Language Freedom: Write your auth service in Rust, your API in Go, your frontend in JavaScript, and your ML pipeline in Python - all running together seamlessly.

Performance: Near-native speed with WebAssembly’s efficiency, but with the safety and portability of sandboxed execution.

📦 True Portability: Build once, run anywhere - from edge devices to cloud servers, from browsers to embedded systems.

🔒 Security by Default: Each component runs in its own sandbox with explicit interfaces - no hidden dependencies or side effects.

  • Microservices: Replace Docker containers with lightweight WASM components
  • Plugin Systems: Add extensibility to your apps with secure, fast plugins
  • Edge Computing: Deploy the same code to CDN edges, IoT devices, and cloud
  • Multi-language Projects: Combine the best tools from different ecosystems

Building WebAssembly components traditionally involves complex toolchains and manual configuration. rules_wasm_component makes it as easy as:

rust_wasm_component_bindgen(
name = "my_service",
srcs = ["src/lib.rs"],
wit = ":my_interfaces",
)

That’s it! Bazel handles the complexity while you focus on building great software.

Rust Integration

Seamless integration with rules_rust for building WebAssembly components with wit-bindgen.

Go Support

TinyGo v0.38.0 with WASI Preview 2 component support and official BytecodeAlliance modules.

C++ Components

Native C++ component development with WASI SDK and Preview2 direct compilation.

JavaScript/TypeScript

ComponentizeJS integration for building WebAssembly components from JS/TS source code.

WAC Composition

WebAssembly Composition (WAC) support for building complex multi-component systems.

OCI Publishing

Publish and distribute components via container registries with multi-registry support.

Digital Signing

Component signing with wasmsign2 and verification for secure deployments.

Performance

Wizer pre-initialization for 1.35-6x startup performance improvements.

WRPC Integration

Remote procedure calls between components with wrpc bindings and distributed architecture.

Multi-Architecture

Build and distribute components for multiple WebAssembly targets and platforms.

Enterprise Security

Security policies, component signing verification, and enterprise-grade deployment controls.

Advanced Composition

Microservices patterns, distributed systems, and hybrid local/remote component orchestration.

Create your first WebAssembly component in just a few steps:

BUILD.bazel
load("@rules_wasm_component//wit:defs.bzl", "wit_library")
load("@rules_wasm_component//rust:defs.bzl", "rust_wasm_component_bindgen")
wit_library(
name = "hello_interfaces",
srcs = ["hello.wit"],
package_name = "hello:world@1.0.0",
)
rust_wasm_component_bindgen(
name = "hello_component",
srcs = ["src/lib.rs"],
wit = ":hello_interfaces",
)

Build WebAssembly components in your preferred language:

Rust

Full Component Model support with wit-bindgen integration and multiple build profiles.

Learn more →

Go

TinyGo v0.38.0 with WASI Preview 2 and official BytecodeAlliance Go modules.

Learn more →

C++

Native Preview2 compilation with WASI SDK and comprehensive error handling.

Learn more →

JavaScript

ComponentizeJS with NPM dependencies, TypeScript support, and optimization.

Learn more →