Setting Up Hot Reload

  1. Hot reloading allows much faster iteration times inside of rsx calls by interpreting them and streaming the edits.
  2. It is useful when changing the styling/layout of a program, but will not help with changing the logic of a program.
  3. Currently the cli only implements hot reloading for the web renderer. For TUI, desktop, and LiveView you can use the hot reload macro instead.

Web

For the web renderer, you can use the dioxus cli to serve your application with hot reloading enabled.

Setup

Install dioxus-cli. Hot reloading is automatically enabled when using the web renderer on debug builds.

Usage

  1. Run:
dx serve --hot-reload
  1. Change some code within a rsx or render macro
  2. Open your localhost in a browser
  3. Save and watch the style change without recompiling

Desktop/Liveview/TUI/Server

For desktop, LiveView, and tui, you can place the hot reload macro at the top of your main function to enable hot reloading. Hot reloading is automatically enabled on debug builds.

For more information about hot reloading on native platforms and configuration options see the dioxus-hot-reload crate.

Setup

Add the following to your main function:

fn main() {
    hot_reload_init!();
    // launch your application
}

Usage

  1. Run:
cargo run
  1. Change some code within a rsx or render macro
  2. Save and watch the style change without recompiling

Limitations

  1. The interpreter can only use expressions that existed on the last full recompile. If you introduce a new variable or expression to the rsx call, it will require a full recompile to capture the expression.
  2. Components, Iterators, and some attributes can contain arbitrary rust code and will trigger a full recompile when changed.