https://github.com/solarkraft/vite-rust-starter
Vite, wasm-bindgen+wasm-pack all set up with auto reloading and simple module imports.
https://github.com/solarkraft/vite-rust-starter
rust-wasm rust-web vite wasm wasm-bindgen wasm-pack
Last synced: about 2 months ago
JSON representation
Vite, wasm-bindgen+wasm-pack all set up with auto reloading and simple module imports.
- Host: GitHub
- URL: https://github.com/solarkraft/vite-rust-starter
- Owner: solarkraft
- Created: 2025-05-16T05:21:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-16T12:13:31.000Z (about 1 year ago)
- Last Synced: 2025-11-23T15:04:51.804Z (7 months ago)
- Topics: rust-wasm, rust-web, vite, wasm, wasm-bindgen, wasm-pack
- Language: TypeScript
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vite Rust Starter
This template is meant to be a scaffold for conveniently building web apps with Rust elements.
## Features
- Web tooling first: You're not locked into rust specific tooling but primarily use pnpm and Vite
- Auto reloading on both Rust and JavaScript changes
- Integrated logs and lifecycles for both systems
- Easily find + replace-able module name
## Technical details
The rust module is exposed to the global namespace under the `RustModule` object.
You can explore its functions by pressing `.` after its name in the browser console.
Try calling `RustModule.hello_alert()`:
You just called a Rust function from JavaScript and that Rust function called a browser function as imported from `gloo::dialogs`!
## Developing
### Prerequisites
- Node.js & pnpm (`npm install --global pnpm`)
- Rust/Cargo
Install dependencies with `pnpm install`. Run with `pnpm dev`.
## Tips / Guides
### Renaming the Rust module
Integrating a Rust module requires hard coding its name in various places.
The name `my-rust-module` was deliberately chosen to make changing it easy: Just do a find + replace.
## Ingredients
This template mainly combines the following components:
- [wasm-pack](https://github.com/rustwasm/wasm-pack): Building WebAssembly packages from the compiled wasm files
- [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/): Automatic binding creation for Rust functions and types
- [vite-plugin-wasm](https://github.com/Menci/vite-plugin-wasm): Nice integration into Vite (loading as ES module, auto reloading)