Quickstart
- Install
rust
usingrustup
. - Install this tool.
- Run
wasm-pack new hello-wasm
. cd hello-wasm
- Run
wasm-pack build --target web
. - This tool generates files in a
pkg
dir - Import it:
import init, { greet } from "./pkg/hello_wasm.js"
, initialize it:await init()
, and then use it:greet()
- To publish to npm, run
wasm-pack publish
. You may need to login to the registry you want to publish to. You can login usingwasm-pack login
.