rsnext/examples/with-webassembly
2020-11-07 13:13:24 -05: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 chore: updated react to v17 on with-webassembly example (#18916) 2020-11-07 13:13:24 -05:00
README.md Undo unrequired readme changes done to examples (#16831) 2020-09-03 19:11:58 +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).