#desktop #server #dioxus #mobile #full-stack #gui #web #server-side #mobile-app #serve-static

dioxus-server

Fullstack utilities for Dioxus: Build fullstack web, desktop, and mobile apps with a single codebase

3 releases

0.7.0-alpha.2 Jul 2, 2025
0.7.0-alpha.1 May 31, 2025
0.7.0-alpha.0 May 14, 2025

#1089 in HTTP server

Download history 165/week @ 2025-05-11 52/week @ 2025-05-18 97/week @ 2025-05-25 267/week @ 2025-06-01 78/week @ 2025-06-08 55/week @ 2025-06-15 141/week @ 2025-06-22 366/week @ 2025-06-29 283/week @ 2025-07-06

852 downloads per month

MIT/Apache

490KB
7.5K SLoC

Dioxus utilities for the Axum server framework.

Example

#![allow(non_snake_case)]
use dioxus::prelude::*;

fn main() {
    #[cfg(feature = "web")]
    // Hydrate the application on the client
    dioxus::launch(app);
    #[cfg(feature = "server")]
    {
        tokio::runtime::Runtime::new()
            .unwrap()
            .block_on(async move {
                // Get the address the server should run on. If the CLI is running, the CLI proxies fullstack into the main address
                // and we use the generated address the CLI gives us
                let address = dioxus::cli_config::fullstack_address_or_localhost();
                let listener = tokio::net::TcpListener::bind(address)
                    .await
                    .unwrap();
                axum::serve(
                        listener,
                        axum::Router::new()
                            // Server side render the application, serve static assets, and register server functions
                            .serve_dioxus_application(ServeConfigBuilder::default(), app)
                            .into_make_service(),
                    )
                    .await
                    .unwrap();
            });
     }
}

fn app() -> Element {
    let mut text = use_signal(|| "Click the button to run a server function".to_string());

    rsx! {
        button {
            onclick: move |_| async move {
                if let Ok(data) = get_server_data().await {
                    text.set(data);
                }
            },
            "Run a server function"
        }
        "Server said: {text}"
    }
}

#[server(GetServerData)]
async fn get_server_data() -> ServerFnResult<String> {
    Ok("Hello from the server!".to_string())
}

Dependencies

~19–48MB
~1M SLoC