← All Workshops

MudEngine Part 10: Desktop with Blitz

Step 4 / 12

Swap the import and launch

The core change is minimal: replace dioxus::launch with dioxus_native::launch, and import from dioxus_native::prelude instead of dioxus::prelude.

The prelude re-exports everything you need: Element, rsx!, #[component], use_signal, use_future, Signal, EventHandler, etc. These are the same types from dioxus-core and dioxus-html — just re-exported through the native renderer.

For fullstack functionality (server functions, set_server_url, use_websocket), you import directly from dioxus (or dioxus-fullstack). This keeps the native renderer separate from the fullstack plumbing.

Open src/main.rs and change the top of the file:

mud-engine/src/main.rs
use std::collections::HashMap;

// Replace `use dioxus::prelude::*` with the native prelude:
use dioxus_native::prelude::*;

// Fullstack imports still come from dioxus/dioxus-fullstack:
use dioxus::fullstack::set_server_url;
use dioxus_fullstack::{use_websocket, Websocket, WebSocketOptions};

use serde::{Deserialize, Serialize};

fn main() {
    #[cfg(not(feature = "server"))]
    set_server_url("http://localhost:8080");

    // Replace dioxus::launch(App) with the native launch:
    dioxus_native::launch(App);
}
🎯 What changed

Only two lines changed:

  1. Importsuse dioxus_native::prelude::* instead of use dioxus::prelude::*
  2. Launchdioxus_native::launch(App) instead of dioxus::launch(App)

Everything else — the components, signals, server functions, WebSocket handling — stays identical. The #[get] macro, #[component] macro, rsx!, use_signal, use_future all work unchanged because they share the same underlying dioxus-core types.

💡 What dioxus_native::prelude exports

The native prelude re-exports from dioxus-core, dioxus-html, dioxus-hooks, and dioxus-signals:

  • rsx! macro
  • #[component] attribute macro
  • Element, VirtualDom
  • use_signal, use_memo, use_effect, use_future, use_resource
  • Signal, ReadOnlySignal, Readable, Writable
  • EventHandler, FormEvent, KeyboardEvent, MouseEvent
  • Key
  • dioxus_core, dioxus_html, dioxus_hooks, dioxus_signals module re-exports

If you need anything not in the prelude (rare), import it from the individual sub-crates:

use dioxus_html::input_data::keyboard_types::Key;
use dioxus_signals::Copyable;
Step 4 / 12