Watch Mode and Hot Reload
During development, you can use various tools to automatically recompile or refresh your application whenever code changes are detected.
cargo-watch Crate
The cargo-watch crate has long been one of the most popular tools for watching source code changes and automatically recompiling the project.
You can install it with:
bash
cargo install cargo-watchHowever, cargo-watch is limited to recompiling and restarting the application. It does not provide a full hot reload experience on its own.
Hot Reload with subsecond and dioxus-cli
The Dioxus team maintains tools like subsecond, which enable a smoother hot reload experience compatible with Axum and other crates in the ecosystem.
To use this workflow in a Sword project:
- Enable the
hot-reloadfeature in yourCargo.toml:
toml
[dependencies]
sword = { version = "x.y.z", features = ["hot-reload"] }- Install
dioxus-cli:
bash
cargo install dioxus-cli- Run your application with
dx serve:
bash
dx serveThis command serves a similar role to cargo run but within a hot-reload-oriented development flow.
When to use each option?
- Use
cargo-watchif you only need automatic recompilation and restarts. - Use
subsecond+dioxus-cliif you want a development experience closer to true hot reload.

