Quickstart - Hello wasm-pack! (original) (raw)
- 1. Introduction
- 2. Quickstart
- 3. Prerequisites
- 4. Commands
- 5. Tutorials
- 6. Cargo.toml Configuration
- 7. Contributing
This documentation isno longer maintained at this domain, and is now maintained at drager.github.io/wasm-pack instead.
Hello wasm-pack!
- Install
rustusing rustup. - Install this tool.
- Run
wasm-pack new hello-wasm. cd hello-wasm- Run
wasm-pack build --target web. - This tool generates files in a
pkgdir - 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.