github DioxusLabs/dioxus v0.7.0-rc.1

pre-release11 hours ago

Today, we’re releasing Dioxus 0.7.0-rc.1 - the second pre-release of Dioxus 0.7.

This release unfortunately took much longer to ship than we expected. While fixing bugs related to dioxus fullstack, we stumbled across a handful of critical issues in our integration with the server_fn crate. Coupled with changes in the dioxus CLI, these issues prevented a large swath of user projects from compiling.

As such, we re-implemented the server function crate, but this time exclusively tailored for Dioxus and Axum. This rewrite was originally planned as a major feature of Dioxus 0.8, but given the severity of the issues, we decided to pull it forward to 0.7. The rewrite unlocks tons of new functionality including things like SSE, flexible error types, custom axum routers, simple websockets, and a rocket-like endpoint definition system.

Here's a quick sneak peek:

use dioxus::prelude::*;

fn main() {
    dioxus::launch(|| {
        let mut message = use_action(get_message);

        rsx! {
            h1 { "Server says: "}
            pre { "{message:?}"}
            button { onclick: move |_| message.call("world".into(), 30), "Click me!" }
        }
    });
}

/// you can now encode query and path parameters in the macro!
#[get("/api/{name}/?age")]
async fn get_message(name: String, age: i32) -> Result<String> {
    Ok(format!("Hello {}, you are {} years old!", name, age))
}

Rust-Conf keynote

I gave a keynote talk at Rust Conf! Check it out! It covers the various projects we've been working on to push Rust forward, including subsecond hot-patching, progress on autoclones in Rust, and more.

Changes to Fullstack

We completely overhauled dioxus-fullstack, fixing a huge number of long-standing bugs and adding tons of new functionality.

These include:

  • New macros for annotating API endpoints (#[get("/api/route")], #[post("/api/:path?query&param")] )
  • Accept pure axum handlers that take FromRequest and IntoResponse bodies
  • Server-only FromRequest extractors
  • A new HttpError type and accompanying trait for returning proper Axum responses
  • Support for anyhow::Error type as a return type from server functions
  • Addition of a Server-Sent-Events (SSE) type
  • Addition of a Websocket type and reactive use_websocket hook for handling websocket connections
  • Addition of a MultipartFormData type that works across web and native
  • Addition of a Streaming<T, E> type without needing to specify an encoding attribute
  • Support for custom encoding types
  • Access to the full axum::extract::Request type in server functions
  • Support for pure SSR apps with hot-reloading powered by subsecond
  • Support for custom axum routers with dioxus::serve
  • Support for Lazy<T> type for lazy async initializers

As mentioned earlier, the fullstack overhaul was originally planned for Dioxus 0.8, but we decided to pull it forward into 0.7, causing a substantial delay.

To get a feel for the new APIs, take a look at the fullstack examples folder. We will be updating fullstack docs this week to prep for the full 0.7 release soon.

Breaking changes to Events: FormData and FileData

Our Form and File APIs have been clumsy for quite a while. In order to support ergonomics improvements with server functions, we revisited our FormData and FileData APIs to make them more consistent with the web platform.

We replaced the old FilesEngine abstraction with a new FileData type with an API that matches the browser.

In addition, we changed how to read the field names and values from forms. Previously, .values() return a HashMap of form values, but now, .values() returns a Vec of form values - again, to better match web APIs.

Breaking changes to dioxus::core APIs

A number of APIs were moved from ScopeId to the Runtime in dioxus_core. This shouldn't impact most users, but anyone building a renderer around Dioxus will notice that some methods no longer exist.

These were changed to reduce our API surface area outside of core types like Runtime and to make it easier to understand where runtime-related errors were occurring.

Updates to Blitz

Blitz saw massive improvements over the past few weeks, notably with the addition of incremental tree construction which makes Blitz substantially faster. Now, Blitz performance is on-par with the Rust GUI ecosystem.

What's Changed

New Contributors

Full Changelog: v0.7.0-rc.0...v0.7.0-rc.1

Don't miss a new dioxus release

NewReleases is sending notifications on new releases.