by davidMcneil

davidMcneil /the-rusty-web

Targeting the web with Rust.

128 Stars 4 Forks Last release: Not found 31 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

The Rusty Web

Website Guide

Note: The contents of this repo are now significantly outdated. Check out rustwasm for the latest and greatest on how to integrate Rust ans WebAssembly.

Discussion on Hacker News.


This project demonstrates a complete, albeit simple, example of integrating Rust code into a web application. This is accomplished by compiling Rust to asm.js or WebAssembly. The basic design pattern this project explores uses Rust to implement CPU bound portions of an app while using existing web technologies to handle user facing, I/O bound pieces. The guide explores this design pattern in detail.

The project compares implementations of the k-means clustering algorithm (this example's CPU bound task) applied to an image. The algorithm gives the resulting image a softened, painted look.



See the guide for steps on installing the dependencies.

Running the Project Natively

From the top level of the project run

cargo run


cargo run --release

The resulting painted image can be found at img/out.jpg.

Running on the Web

From the top level of the project...

Build the asm.js version

cargo build --release --target asmjs-unknown-emscripten

Build the WebAssembly version

cargo build --release --target wasm32-unknown-emscripten

From the website/ directory...

Install node dependencies

npm install

Build the website (build results can be found in website/dist)

npm run build

or build the website in release mode

npm run build-release

or start a web server, website is served at http://localhost:9000/

npm run start

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.