WebAssembly (WASM) is a portable, low-level binary code format that runs on modern browsers, just like JavaScript does. In fact, WebAssembly is also interoperable with JavaScript. You can transpile most program source code down to WebAssembly and run it on the browser with or without JavaScript.

Rust is fast, making the language a viable option for building WebAssembly programs. There are many Rust libraries and frameworks to help, with support for the tools you use to build web apps.

1. The Sycamore Library

The-Sycamore-homepage-1

Sycamore is a fast, ergonomic, and intuitive SolidJS-like reactive framework. You can use it to build web applications in Rust that leverage the power of WebAssembly. Sycamore provides most of the functionality you'll need to create a web app frontend in Rust, so you won't need to write JavaScript.

Sycamore also provides a router and JavaScript interoperability over Wasm-Bindgen using JS-sys or Web-Sys. The project intends to release testing and CSS functionality soon.

To use Sycamore, you'll need a recent version of Rust—the wasm32-unknown-unknown target. You'll also need Trunk to build and bundle your application. Since Sycamore is new, it will be risky to use the main branch library in production, except if you resort to an earlier release.

2. The Yew Framework

Yew is a Rust framework for building multithreaded frontend web apps using WebAssembly. It allows you to write Rust code and transpile your Rust code to WASM, which can run on any device with WASM support. Yew is interoperable with JavaScript (you can use your npm packages), and the framework provides a macro for interacting with HTML elements with Rust, like JSX in React.

You can get started with Yew using the Trunk application bundler or WASMPack. Check out the documentation for how to get started, interact with HTML and DOM APIs and transpile your Rust code to WebAssembly.

The Yew project is very popular, with over twenty thousand stars on Github and five thousand users. Yew is stable, but the project is not production ready, and the code base is changing, so you might experience errors and breaks.

3. The Percy Library

A screenshot of the Percy home page

Percy is a collection of Rust libraries for building frontend web apps powered by WebAssembly. Percy supports instant server-side rendering. The project excels at building search-engine-friendly single-page applications (SPAs).

Percy provides an html! macro for generating virtual DOMs. You can render these into DOM elements in the frontend or use them for operations in the backend of your application.

Percy is still very new, and although the library is not production ready, the project is very popular, with over two thousand stars on Github.

4. The Seed Framework

A screenshot of the Seed home page

Seed is a batteries-included, full-stack WebAssembly-powered framework for building fast web apps in Rust. The Seed framework provides a templating system that uses a macro syntax instead of Yew's JSX-like syntax. It also has a built-in state management system to enhance productivity.

Seed is new, and pre-built components like date pickers are rare. Although Seed doesn't currently support server-side rendering, the project aims to include it soon. Otherwise, Seed is feature-complete, and you can build production-ready web applications with it. Seed also uses the Elm architecture with minimal configuration. You can build and bundle your applications using Trunk, Web Bundler or Seeder.

You can also use Seed for the backend of your web application. Seed provides functionality for building REST or GraphQL APIs with routing and authentication support and AuthO integration.

5. The MoonZoon Toolkit

MoonZoon is an easy-to-use, full-stack, WebAssembly-supported framework for frontend and backend applications. You can write Rust without having to write HTML, CSS, and JavaScript on the frontend or REST, GraphQL, or SQL on the backend. MoonZoon is fast, simple, scalable, and SEO-friendly. It provides a CLI application to build web apps that are easy to deploy.

The MoonZoon project philosophy is to create a very simple tool with no special terminology, artificial barriers, or dogma. Using it, you can focus on building web applications as you please. You’ll need to have WASM-Pack installed to build the front end. The backend of a MoonZoon application runs on Actix-web and Warp, both popular Rust backend frameworks. MoonZoon also provides authentication functionality.

The MoonZoon documentation isn’t hosted at the moment. To use the tool, you can check out the markdown files in the docs folder via the project’s GitHub repository.

You May Have Interacted With WebAssembly

WebAssembly was first released in 2017, and the World Wide Web Consortium (W3C) made WebAssembly a web standard in 2019. Since 2019, companies like Cloudflare, Google, and Dropbox have used the technology in production.

Google Earth uses WebAssembly, Cloudflare uses it for Cloudflare Workers, and Dropbox uses WebAssembly for a codec on its website.