Compile a Rust function into WebAssembly and import it in a JavaScript project as if it were a regular npm package.
Run your Rust and WebAssembly code in a real browser environment during testing to catch browser-specific bugs.
Publish your compiled Rust WebAssembly module to the npm registry so other JavaScript developers can install it.
Bootstrap a new Rust WebAssembly project from a template with wasm-pack new.
Requires Rust 1.30+ and the wasm-pack installer script, first build also downloads wasm-bindgen automatically.
wasm-pack is a command-line tool that handles the workflow for compiling Rust code into WebAssembly and packaging the result for use in JavaScript projects. WebAssembly is a binary format that modern browsers and Node.js can run at near-native speed. It lets you write performance-critical code in a language like Rust and call it from JavaScript as if it were a regular package. Without wasm-pack, getting Rust output into a JavaScript project involves several steps and tools that need to be coordinated manually. wasm-pack bundles those steps into a small set of commands. The build command compiles a Rust crate into a WebAssembly binary and wraps it with the JavaScript glue code needed to call it from a browser or Node.js. The output is a package compatible with npm and bundlers like webpack, so it slots into existing JavaScript workflows without requiring a different toolchain. The new command generates a project from a template to help you get started quickly. The test command runs tests in a browser environment, which is useful when the code needs to behave correctly inside a web page. The pack and publish commands create a distributable tarball from your compiled package and optionally push it to the npm registry so others can install it. Logging is available through the standard RUST_LOG environment variable, which lets you adjust the verbosity of output during builds. The tool requires Rust version 1.30.0 or later. Installation is handled through the project's own installer script. The README is short and points to a dedicated documentation site for the quickstart guide, full command reference, and contribution instructions.
← wasm-bindgen on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.