rsnext/examples/with-webassembly
Nick Babcock 6c59b77702
Switch to stable rust for with-webassembly example (#22582)
Since Rust 1.30 (released Oct 2018), the wasm target is supported on stable.

ref: https://rustwasm.github.io/book/game-of-life/setup.html#the-rust-toolchain
2021-02-27 21:48:49 +00:00
..
pages Upgrade to Prettier 2 (#13061) 2020-05-18 15:24:37 -04:00
src Add WebAssembly example 2018-09-17 21:48:06 +02:00
.gitignore Added .gitignore to examples that are deployed to vercel (#15127) 2020-07-16 10:52:23 -04:00
add.wasm Add WebAssembly example 2018-09-17 21:48:06 +02:00
next.config.js Improve linting rules to catch more errors (#9374) 2019-11-10 19:24:53 -08:00
package.json Switch to stable rust for with-webassembly example (#22582) 2021-02-27 21:48:49 +00:00
README.md Fix deploy buttons URLs (#20834) 2021-01-07 01:40:29 +00:00

WebAssembly example

This example shows how to import WebAssembly files (.wasm) and use them inside of a React component that is server rendered. So the WebAssembly code is executed on the server too. In the case of this example we're showing Rust compiled to WebAssembly.

How to use

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example with-webassembly with-webassembly-app
# or
yarn create next-app --example with-webassembly with-webassembly-app

This example uses Rust compiled to wasm, the wasm file is included in the example, but to compile your own Rust code you'll have to install Rust.

To compile src/add.rs to add.wasm run:

npm run build-rust
# or
yarn build-rust

Deploy it to the cloud with Vercel (Documentation).