← All Workshops

MudEngine Part 10: Desktop with Blitz

Step 3 / 13

Add dioxus-native

The dioxus-native crate provides the Blitz renderer for Dioxus. It wraps the core Dioxus virtual DOM with a native window powered by winit and renders HTML/CSS via Vello (a GPU-accelerated 2D vector engine).

The crate is published on crates.io at version 0.7.10, matching the Dioxus 0.7 ecosystem.

Add dioxus-native alongside the existing dioxus (with fullstack) dependency. The dioxus-native crate depends on the same dioxus-core, dioxus-html, and dioxus-signals crates, so they share the same types and macros.

We also keep the server feature for the Axum server binary:

mud-engine/Cargo.toml
[package]
name = "mud-engine"
version = "0.1.0"
edition = "2024"

[dependencies]
dioxus = { version = "=0.7.10", features = ["fullstack"] }
dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
dioxus-fullstack = "=0.7.10"
serde = { version = "1", features = ["derive"] }
uuid = { version = "1", features = ["v4", "js"] }

# add these:
tokio = { version = "1", features = ["sync", "time"] }
toml = "1.1"

# `server`/`web` stay defined because src/game/{server,persistence}.rs gate
# their server-side code behind `#[cfg(feature = "server")]` — carried over
# from Part 6 (and picked up by rust-analyzer below).
[package.metadata.rust-analyzer]
cargo.features = ["server", "web"]

[features]
default = ["web"]
web = ["dioxus/web"]
server = ["dioxus/server"]

# `dioxus-native` must stay out of the wasm build: its blitz-net → tokio/net
# chain trips tokio's wasm feature gate ("Only features sync,macros,io-util,
# rt,time are supported on wasm"), so `dx serve` would fail compiling the
# web client. Gate it to native targets only — the desktop client runs on the
# host via `cargo run`, while `dx serve` never needs it.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dioxus-native = "0.7"

[lints.rust]
unused = "allow"
🧱 Why dioxus-native is target-gated

Don't put dioxus-native in plain [dependencies]. The crate is a native-only renderer (winit + WGPU), but dx serve compiles your crate for three targets — the Axum server, the WASM web client, and the native client (cargo run). If dioxus-native is an ungated dependency, it gets pulled into the WASM graph too.

That breaks dx serve with:

error: Only features sync,macros,io-util,rt,time are supported on wasm.

Why: dioxus-native's blitz-net enables tokio/net, and recent tokio releases refuse the net/fs/process/rt-multi-thread feature family on wasm32. Gate the dependency to non-WASM targets and the web bundle compiles again — the desktop client only ever builds on the host anyway.

🔍 What's in dioxus-native

The dioxus-native crate pulls in several subsystems:

CrateRole
blitz-domThe core DOM abstraction — style resolution, layout, event handling
blitz-shellWindow integration — winit event loop, AccessKit accessibility
blitz-paintTranslates the DOM tree into draw commands
anyrender / anyrender_velloThe rendering abstraction — Vello draws shapes and text on the GPU
styloMozilla's Servo CSS engine — parses and resolves styles
taffyFlexbox and CSS Grid layout engine
winitCross-platform window and input handling

This is a fundamentally different stack from the system WebView used by dioxus/desktop. Everything is in Rust — no Chromium, no WebKit, no JavaScript.

⚠️ Experimental warning

Blitz is pre-alpha software. You will encounter:

  • Missing CSS features (some selectors, animations, etc.)
  • Rendering glitches (text layout, complex backgrounds)
  • Performance issues (CPU-based Vello fallback on some hardware)
  • API changes between versions

This workshop is an exploration of where Dioxus native rendering is headed, not a production-ready setup. Expect to file bugs if things go wrong!

Step 3 / 13