Getting Started
This documentation assumes the developer is already familiar with Rust programming. To learn more about Rust, check out the Rust Book.
Install Rust
First, you’ll need to install Rust. Follow the official instructions to get started.
You will also need the wasm32-unknown-unknown
target installed. This installs the necessary tools
to compile your code to WebAssembly.
Minimum Supported Rust Version (MSRV) and Rust edition
The minimum supported Rust toolchain is v1.63.0
. Sycamore is not guaranteed to (and probably
won’t) compile on older versions of Rust.
Sycamore only works on Rust edition 2021. Even though most crates written in edition 2021 are backward compatible with older editions, this is not the case for Sycamore because Sycamore’s proc-macro generates code that is only compatible with edition 2021. Furthermore, the disjoint capture in closures feature greatly improves the ergonomics when working with Sycamore’s reactivity.
Install Trunk
Trunk is the recommended build tool for Sycamore. If you are from JS land, Trunk is like webpack or rollup but specifically tailored towards Rust + WASM apps.
You can use one of the following command to install Trunk on your system:
# Install via homebrew on Mac, Linux or Windows (WSL).
# Install a release binary (great for CI).
# You will need to specify a value for ${VERSION}.
|
# Install via cargo.
For more information, head over to the Trunk website
Create a new Sycamore project
Create a new Rust project using cargo
:
You now need to add Sycamore to your new project’s dependencies. Add the following to your
Cargo.toml
file in your project folder:
= "0.8"
Note: Sycamore is currently being developed at a rapid pace. To have access to the latest features, consider using a git dependency instead.
However, breaking changes are introduced all the time. It is therefore recommended to also specify a specific commit hash to prevent your code from randomly breaking. You can find the latest commit hash here (to the right of each commit).
# Make sure you update the rev to the latest commit hash. = { = "https://github.com/sycamore-rs/sycamore", = "fc640d313e66f9a6af422fae44f4f72fa86280cc" }
You should now be all set for your Sycamore adventure!