$ ls ./menu

© 2025 ESSA MAMDANI

cd ../blog
2 min read

What is Dioxus, How to Build?

> Build for web, desktop, and mobile, and more with a single codebase. Zero-config setup, integrated hot-reloading, and signals-based state management. Add backend functionality with Server Functions and bundle with our CLI.

Audio version coming soon
What is Dioxus, How to Build?
Verified by Essa Mamdani

Dioxus is a fullstack and cross-platform framework for building web, desktop, mobile, and server apps using Rust. It offers a React-like development experience with features like components, props, and hooks, but with Rust's performance and safety. Key features include ergonomic state management, type-safe routing, an integrated bundler, and instant hot-reloading. Dioxus supports various platforms, including web (with SSR and hydration), desktop (macOS, Linux, Windows), and mobile (Android, iOS).

Building with Dioxus: A Step-by-Step Guide

The process of building with Dioxus involves several key steps:

1. Prerequisites:

2. Installation:

Install the Dioxus CLI (dx) using:

bash
1cargo install dioxus-cli

If you encounter OpenSSL errors, ensure the necessary dependencies are installed (refer to https://docs.rs/openssl/latest/openssl/#automatic for details).

3. Creating a New Project:

Use the CLI to create a new project:

bash
1dx new my-app
2cd my-app

You'll be prompted to select a platform (Web, Desktop, Mobile, etc.), a styling library (e.g., vanilla CSS), and whether to enable routing.

4. Running Your App:

Start the development server:

bash
1dx serve

For LiveView templates, use dx serve --desktop. For web targets, the application will be served at a specified address.

5. Core Concepts:

  • Components: Reusable UI elements built using functions returning Element. The #[component] attribute simplifies component creation and prop management.
  • rsx! Macro: A JSX-like macro for creating elements with attributes, listeners, and children. Attributes and listeners are listed before children.
  • Hooks: Reusable logic units for managing state and side effects within components. They start with use_ (e.g., use_signal). Adhere to the "rules of hooks" for correct usage.

6. Example: A Simple Counter

A basic Dioxus counter app demonstrates core concepts:

rust
1use dioxus::prelude::*;
2
3#[component]
4fn App() -> Element {
5    let mut count = use_signal(|| 0);
6
7    rsx! {
8        div { "Count: {count}" }
9        button { onclick: move |_| count += 1, "Increment" }
10        button { onclick: move |_| count -= 1, "Decrement" }
11    }
12}

7. Further Learning:

Explore the Dioxus documentation (https://dioxuslabs.com/learn/0.6/) for tutorials, guides, and advanced topics like server-side rendering, concurrent rendering, and platform-specific details. The Dioxus website also serves as a testbed for new features.

Dioxus Multiplatform Icon
Dioxus Hot Reloading
Dioxus Android and iOS Support
Dioxus Bundling
Dioxus Documentation
Dioxus Community