This is prerelease for our new server functions rewrite and Axum 0.7 support.
This should be a relatively feature-rich release, with limited breaking changes.
I'm interested in gathering feedback in the discussion associated with this release.
Migration
Actix
- You can remove any explicit
.handle_server_fns()
call in yourmain.rs
, as server functions are now handled in.leptos_routes()
- The current
extract
function has been removed, and replaced with a newextract
that has the same API as the currentextractor
. I think this API is strictly better, but please share feedback if you disagree.
Axum
- This release supports Axum 0.7, so you'll need to migrate from Axum 0.6. The easiest way to do this is probably to consult the diff on one of the examples.
- You can remove any explicit
.handle_server_fns()
call in yourmain.rs
, as server functions are now handled in.leptos_routes()
- The current
extract
function has been removed, and replaced with a newextract
that has the same API as the currentextractor
. I think this API is strictly better, but please share feedback if you disagree. RequestParts
has been removed, ashttp::request::Parts
now implementsClone
: anyuse_context::<RequestParts>()
should be updated to useParts
directly instead.
Features
A rewritten server function system that is backwards-compatible, but reduces binary size and increases flexibility, specifically by allowing
- automatic setup of server fn handlers with
.leptos_routes()
from the integrations - a variety of additional built-in encodings (rkyv, multipart forms/file uploads) in addition to the current set (GET URL, POST URL, CBOR, Rkyv) (#1868, #1989)
- support for streaming responses from server functions (#1284)
- ability to create custom user encodings for input and output by deriving
IntoReq
,FromReq
,IntoRes
, and/orFromRes
traits - ability to mix and match encodings easily: This server function should be a JSON POST request and a ByteStream response, this one should be GET URL request and an rkyv response, etc.; any combination of the encodings above is supported
- custom error types (#1657)
- a
#[middleware]
macro to add per-server-function middleware from the Tower or Actix ecosystems (#1461)
Note: The additional included encodings (serde_lite
, rkyv
, multipart form data) are all enabled by additive features on the server_fn
crate. If you want to use them you can just add that crate as a dependency and enable the required features.
Example: You can find a comprehensive example of these new features in the new server_fns_axum
example.
What's Changed since 0.6.0-beta
- fix: ci stopped detecting leptos or example changes by @agilarity in #2194
- fix: routing regressions caused by
trailing_slash
support by @gbj in #2203 - examples: update
axum-session
because old version was yanked by @gbj in #2205 - docs:
View::render_to_string
panic by @chrisp60 in #2200 - fix:
leptos_meta
should not enabletracing
feature onleptos
by default (closes #2158) by @gbj in #2211 - feat:
Default
forLeptosOptions
,ConfFile
by @chrisp60 in #2208 - Make static rendered routes servable and provide context to static_params by @NiklasEi in #2207
- chore: minimize features activated with
leptos_axum
's default feature (#1846) by @gbj in #2213 - feat: add support for custom encoding to
#[server]
macro by @gbj in #2216 - fix:
.refetch()
should not include any tracked reads by @gbj in #2222
Full Changelog: v0.6.0-beta...0.6.0-rc1