Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.02 KB

README.md

File metadata and controls

60 lines (46 loc) · 1.02 KB

React Application using Web-Assembly (Rust)

You must have node (and npm) installed.

Initialize React project

npx -y create vite@latest wasm-rust-react -- --template react-ts

Install tools

Install rust related tools using the setup script:

bash setup.sh

Create new rust lib:

cargo new rust-libs --lib
cd rust-libs
cargo add wasm-bindgen

Change crate-type in Cargo.toml and add rust byproducts in .gitignore.

[lib]
crate-type = ["cdylib"]

Build the rust libs:

wasm-pack build --target web

Install/add package to npm:

npm i ./rust-libs/pkg

Or add "rust-libs": "file:rust-libs/pkg" to package.json dependencies, and run:

npm i

Start development server:

npm start

To update rust dependencies:

cargo install cargo-update --features vendored-openssl
cargo install-update -a

Resources