This example shows how to import WebAssembly files (.wasm
) and use them inside of a Nullstack component in both server and client environments. In the case of this example we're showing Rust and Go compiled to WebAssembly.
Deploy it now with Vercel or preview on StackBlitz:
Execute nulla create
with npm:
npx nulla create --example with-webassembly with-webassembly-app
Then deploy it with Vercel, Heroku or Netlify.
The WASM file is included in the example, but to compile your own Rust code you'll have to install Rust.
To compile src/rust/src/main.rs
to src/rust/main.wasm
run:
npm run build:rust
# or
yarn build:rust
# or
pnpm build:rust
The WASM file is included in the example, but to compile your own Go code you'll have to install both Go and TinyGo (used to generate optimized Go binaries).
To compile src/go/src/main.rs
to src/go/main.wasm
run:
npm run build:go
# or
yarn build:go
# or
pnpm build:go