rsnext/examples/with-webassembly
Jeff Mendez 616e0d7ee8
chore(examples): fix experiments loading npm wasm (#38348)
* enables default config that handles npm wasm bundles



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-06 13:05:14 +00:00
..
pages [edge api] allow wasm usage (#37836) 2022-06-20 15:08:40 +02: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 chore(examples): fix experiments loading npm wasm (#38348) 2022-07-06 13:05:14 +00:00
package.json Remove licence from all example/package.json that has them (#28007) 2021-08-14 10:48:39 -05:00
README.md Update pnpm create next-app for latest pnpm 6 and 7 (#37254) 2022-05-27 21:21:40 +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.

Preview

Preview the example live on StackBlitz:

Open in StackBlitz

How to use

Execute create-next-app with npm, Yarn, or pnpm 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
# or
pnpm 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