Skip to content
Select theme

Speed up React with WebAssembly

What you end up with: a React app where the slowest function runs in Rust, compiled to WebAssembly, with benchmarks that show what actually got faster — and, more usefully, what did not.

The finished app: a hundred thousand items searched in a worker, with the frame meter that says what a keystroke costs

The web is where most developers are, and WebAssembly is the shortest path from that world into Rust. It is also the track where people most often fool themselves: “10x faster in the benchmark” usually means “we measured the wrong thing”. Here you measure the browser, not the microbenchmark.

  • A React app that renders and searches a large dataset in the browser
  • The same logic in JavaScript and in Rust/WASM, with a switch between them
  • wasm-bindgen glue for strings, arrays and structs
  • A Web Worker so the UI never blocks
  • A benchmark page using performance.now(), plus the size cost of the .wasm bundle
  • A production build with preloading and a real size budget

If you have never written Rust before, do not start here — the basics and ownership first, then come back; the whole point of this track is that you can tell which side of the boundary the work belongs on.

react-wasm/ in the examples repository — the JS version, the Rust version, and the benchmark harness.