Getting Started
Installation
- Install Rust
- Clone Zaplib:
git clone https://github.com/Zaplib/zaplib.git
- Navigate to the repo, install the Cargo extension for Zaplib, and the dependencies:
cd zaplib
cargo install cargo-zaplib
cargo zaplib install-deps
If you're going to do local development of Zaplib, be sure to add the --devel
flag which installs some more dependencies, like Zapium binaries.
cargo zaplib install-deps --devel
Examples
Now you're ready to run a simple example natively. Here are some fun ones to play with:
cargo run -p example_single_button
cargo run -p example_charts
cargo run -p example_text
cargo run -p example_lightning --release
(best to do a release build; see below)cargo run -p example_bigedit --release
(best to do a release build; see below)
Feel free to check out the examples
directory for more examples to play with! You can also view most of these on our Introduction and Demos pages.
Warning: On Mac we currently have a memory leak bug, so some examples might crash after a while. Windows doens't work at all currently. Linux hasn't been tested very well recently. WebAssembly (below) should generally work well though. Early alpha software.. stay tuned!
WebAssembly Build
Of course, Zaplib is a WebAssembly framework, so let's run these in Chrome (more browser support coming soon):
- Build all the examples:
cargo zaplib build --workspace
- Run a server (this will also build the JS dependency):
cargo zaplib serve
- Navigate Chrome to:
http://localhost:3000/zaplib/examples/example_single_button
Release Build
For a more performant build, add the --release
flag, e.g.:
Native
cargo run -p example_single_button --release
WebAssembly
cargo zaplib build -p example_single_button --release
You'll also need to add the ?release
query param:
http://localhost:3000/zaplib/examples/example_single_button/?release
Next Steps
- Set up your developer environment.
- Dive into some tutorials.
- Look at some example code.
example_single_button
is a good place to start if you're coming from ReactJS.