This project demonstrates a simple WebAssembly program written in Rust. The program implements a counter that can be incremented and decremented.
Before you begin, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/ly-nld/wasm-counter.git cd wasm-counter
-
Build the Rust project:
cargo build --target wasm32-unknown-unknown
-
Generate JavaScript bindings:
wasm-bindgen target/wasm32-unknown-unknown/debug/wasm_counter.wasm --out-dir www --web
-
Serve the project using a local server:
# You can use http-server or any other server of your choice, for example, python -m http.server npx http-server www
-
Open your browser and navigate to http://localhost:8080 (or the port used by your local server).
- The webpage will display the current counter value.
- Click the "Increment" button to increase the counter.
- Click the "Decrement" button to decrease the counter.
This project is licensed under the MIT License.