A repo to test WASM with NextJS.
Install dependencies:
cd web
yarn
Ensure wasm-pack
is installed:
cargo install wasm-pack
Compile the Rust code and start the NextJS dev server:
cd web
yarn dev:wasm
- Create a new Rust crate in
wasm/
:
# inside nextjs root folder
cd web
cargo new --lib <name>
- Add the crate to
wasm/Cargo.toml
:
[dependencies]
wasm-bindgen = "0.2.85"
[lib]
crate-type = ["cdylib"]
- Install module as depencency in
web/package.json
:
{
"dependencies": {
"<name>": "file:../wasm/<name>"
}
}
- Install Install dependencies:
cd web
yarn
cd <lib-name>
yarn