MudEngine Part 10: Desktop with Blitz
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:
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); }
Only two lines changed:
- Imports —
use dioxus_native::prelude::*instead ofuse dioxus::prelude::* - Launch —
dioxus_native::launch(App)instead ofdioxus::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.
The native prelude re-exports from dioxus-core, dioxus-html, dioxus-hooks, and dioxus-signals:
rsx!macro#[component]attribute macroElement,VirtualDomuse_signal,use_memo,use_effect,use_future,use_resourceSignal,ReadOnlySignal,Readable,WritableEventHandler,FormEvent,KeyboardEvent,MouseEventKeydioxus_core,dioxus_html,dioxus_hooks,dioxus_signalsmodule 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;