
I recently set out to finally get hot reloading working for my Rust GraphQL API, after getting annoyed by the usual cargo watch flow, which would kill my server in between code changes and it finishing the rebuild + setup.
I had previously played around with subsecond from Dioxus, while it was still in beta, but hadn't had much success. Sometime in August last year (2025), a few improvements got added in PR #4588, namely convenience functions for serving async functions with hot reloading. I did wish their own docs on hot reloading would have mentioned it 😮💨
So it was time to give it another try!
The process was pretty straightforward:
cargo add dioxus_devtools --features servedioxus_devtools::serve_subsecond_with_argscurl -sSL https://dioxus.dev/install.sh | bash (see docs)dx serve --hot-patchI'll add a few more details to each of the steps below.
The only dependency we need is the dioxus-devtools crate (version 0.7.3 as of writing this).
Importantly we need to add the serve feature to it (cargo add dioxus_devtools --features serve). This is what gives us dioxus_devtools::serve_subsecond_with_args.
The restructure of our application's entry point was one of the less obvious things, at least until #4588 got merged. We'll do it in three simple steps:
This could look something like this, with your main entry point being:
1
2 async 3 4 5 6 7 8
And your setup_app_env looking like this:
1
2 3 4 5
6
7 async 8 9 10 11 12 13
and server could look something like:
1 async 2 3 4 5 6 7 8 9
You'll of course need to adjust this to your actual code, but I thought I'd give a slightly more complex example to illustrate the point.
Finally, we'll be running the hot reloading server with using the dioxus cli which takes care of coordinating with subsecond for rebuilding our app. Follow their instructions to install it (or run curl -sSL https://dioxus.dev/install.sh | bash), and then you should now have access to dx serve --hot-patch which will start the server with hot reloading, looking something like this:
Beautiful! 🤌
You can now code away happily and speed up your fullstack work!
I've been using this for a few days now for our main GraphQL API serving the backend for Yaay, and it's been a quite nice addition as a DX improvement.
A big thanks to the amazing team at Dioxus for making subsecond possible to use outside of the Dioxus framework, and for pushing the frontier of Web dev-like DX in Rust!
As mentioned earlier, you probably don't want this out in production, so I'd recommend putting it behind a feature flag. I've personally gone with local.
You'll need a small change to your entry point:
1
2
3 async 4 5 6
7
8
9
10 async 11 12 13 14 15 16 17 18
and you can also adjust your dependencies to only include the dioxus-devtools crate when the local feature is enabled:
1 # ...rest of your Cargo.toml
2 []
3 # Add optional dependencies when the `local` feature is enabled
4 = [
5 "dep:dioxus-devtools",
6 ]
7
8 []
9 = { = "0.7.3", = true, = ["serve"] }
10 # ..rest of your dependencies
Some links that were helpful in piecing all of this together: