cargo leptos 0.6.0-rc1

latest releases: 0.7.0-rc1, 0.7.0-rc0, 0.7.0-preview2...
9 months ago

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 your main.rs, as server functions are now handled in .leptos_routes()
  • The current extract function has been removed, and replaced with a new extract that has the same API as the current extractor. 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 your main.rs, as server functions are now handled in .leptos_routes()
  • The current extract function has been removed, and replaced with a new extract that has the same API as the current extractor. I think this API is strictly better, but please share feedback if you disagree.
  • RequestParts has been removed, as http::request::Parts now implements Clone: any use_context::<RequestParts>() should be updated to use Parts 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/or FromRes 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 enable tracing feature on leptos by default (closes #2158) by @gbj in #2211
  • feat: Default for LeptosOptions, 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

Don't miss a new leptos release

NewReleases is sending notifications on new releases.