616e0d7ee8
* 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) |
||
---|---|---|
.. | ||
pages | ||
src | ||
.gitignore | ||
add.wasm | ||
next.config.js | ||
package.json | ||
README.md |
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:
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