wasm-bindgen

Core Rust library and CLI tool for facilitating high-level interactions between Rust/WebAssembly and JavaScript. The #[wasm_bindgen] macro generates JavaScript glue code that allows calling Rust functions from JavaScript and vice versa. Handles type conversion, memory management, and DOM access. The foundation for all Rust-to-browser compilation workflows, used by wasm-pack to build npm packages from Rust.

Evaluated Mar 06, 2026 (0d ago) v0.2+
Homepage ↗ Repo ↗ Developer Tools rust webassembly wasm browser javascript interop ffi typescript
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
98
/ 100
Is it safe for agents?
⚡ Reliability
80
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
78
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
88
Secret Handling
100

WASM sandbox provides memory isolation. Rust memory safety prevents buffer overflows and use-after-free. Generated JS glue code handles type coercion safely.

⚡ Reliability

Uptime/SLA
90
Version Stability
78
Breaking Changes
75
Error Recovery
78
AF Security Reliability

Best When

You have performance-critical code in Rust that needs to run in the browser, or you're building a Rust+WASM npm package for JavaScript consumption.

Avoid When

You're targeting server-side execution, don't need browser interop, or want a simpler WASM toolchain — check AssemblyScript or Emscripten for other languages.

Use Cases

  • Compile Rust code to WebAssembly and call it from JavaScript/TypeScript with automatic type bindings generated
  • Expose Rust functions and types to JavaScript with #[wasm_bindgen] annotations for performance-critical browser code
  • Call browser APIs (fetch, DOM, Canvas, WebGL) from Rust code using the web-sys and js-sys crates
  • Build npm packages from Rust code using wasm-pack that work in Node.js, browsers, and bundlers
  • Port compute-intensive Rust algorithms to the browser without rewriting in JavaScript

Not For

  • Server-side Rust — wasm-bindgen targets browser/WebAssembly environments specifically; use standard Rust for servers
  • Node.js-only usage without browser DOM needs — consider NAPI-RS for native Node.js addons instead
  • Teams without Rust experience — the learning curve is significant; consider AssemblyScript for simpler WASM

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Build toolchain library. No authentication required.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Apache 2.0 and MIT dual license. Part of the Rust WebAssembly working group.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • wasm-bindgen version in Cargo.toml must exactly match wasm-bindgen-cli version — version mismatch causes cryptic 'schema version mismatch' errors at runtime
  • All types passed across JS/Rust boundary must be #[wasm_bindgen] compatible — complex Rust types need custom serialization (serde-wasm-bindgen or wasm-bindgen JsValue)
  • Panics in Rust WASM code cause the WASM module to abort and become unusable for the session — must catch all potential panics
  • Memory is not automatically managed across JS/Wasm boundary — Rust objects passed to JS must be explicitly .free()'d in JavaScript or memory leaks occur
  • COOP/COEP headers required for SharedArrayBuffer (needed for multi-threading with wasm-bindgen-rayon) — same cross-origin isolation constraint as WebContainers
  • wasm-pack is the recommended build tool for npm packages — using wasm-bindgen CLI directly requires manual bundler configuration

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for wasm-bindgen.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered