NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #4750 most downloaded on crates.io
DOM operations for the Leptos web framework.
Latest stable
0.8.8
Last release 20 days ago
31 Oct 2026
Release timing varies
gaps range from 8 days to 5 months
Most releases are documented
notes for 50 of the last 60 stable releases
4 versions withdrawn
withdrawn after publishing
4 years old
123 releases · first in 2022
Drag across the ruler to compare, or tap a release to open it.
This should be a relatively feature-rich release, with limited breaking changes.
This is a beta release 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.
.handle_server_fns() call in your main.rs, as server functions are now handled in .leptos_routes()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..handle_server_fns() call in your main.rs, as server functions are now handled in .leptos_routes()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.A rewritten server function system that is backwards-compatible, but reduces binary size and increases flexibility, specifically by allowing
.leptos_routes() from the integrationsIntoReq, FromReq, IntoRes, and/or FromRes traits#[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.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
…the feature immediately. This meant a semver-breaking change between 0.5.6 and 0.5.7, so I have yanked 0.5.5 and 0.5.6 of all the crates.
This has been a rocky week for releases. While finalizing the work on 0.6.0, I intended to publish a final 0.5.5 that would contain all the remaining changes to the 0.5 series. Unfortunately, this release contained two serious issues:
trailing_slash changes to the router in 0.5.5 broke the current routing behavior in several situations (see #2203 for details)Because some (many?) existing 0.5 apps would break with this new feature under 0.5 — and worse, because they would compile and then either panic or display the wrong page — I decide to revert the feature immediately. This meant a semver-breaking change between 0.5.6 and 0.5.7, so I have yanked 0.5.5 and 0.5.6 of all the crates.
We've added some appropriate regression tests for those issues. Apologies to anyone whose work was affected by this!
Fix issue were doc comments on server functions caused an error. Sorry bout that!
Fix issue were doc comments on server functions caused an error. Sorry bout that!
Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.5...v0.5.6
This is a (mostly) bug fix and documentation improvements release. If you're interested in the full list, check out the full What's Changed list below
This is a (mostly) bug fix and documentation improvements release. If you're interested in the full list, check out the full What's Changed list below.
@NfNitLoop discovered that by default the leptos_router strips trailing slashes from routes, which might not be what users expect. By default, leptos_router drops the trailing slash on /foo/. He's added a new optional setting on Router that could allow you to keep the slashes and have routes for both /foo and /foo/ or redirect from /foo/ to /foo. Check out the docs for details: https://docs.rs/leptos_router/0.5.5/leptos_router/enum.TrailingSlash.html
Thanks @NfNitLoop!
Thanks to all our new and existing contributors, the 0.6 alpha will be coming out soon with fancy new server functions, so don't go away!
spawn_local by @itowlson in https://github.com/leptos-rs/leptos/pull/2066<A/> and <Form/> (closes #2076) by @gbj in https://github.com/leptos-rs/leptos/pull/2096mount_to_body accept FnOnce closures (closes #2115) by @NKID00 in https://github.com/leptos-rs/leptos/pull/2116<Transition/> fallback should show on if client-rendered (closes #2123) by @gbj in https://github.com/leptos-rs/leptos/pull/2128#[component] or #[island] function signature (closes #2133) by @gbj in https://github.com/leptos-rs/leptos/pull/2134cargo-make and examples (see #2141) by @gbj in https://github.com/leptos-rs/leptos/pull/2150trace to reduce verbosity by @gbj in https://github.com/leptos-rs/leptos/pull/2176Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.4...v0.5.5
v0.5.3 inadvertently introduced a regression in the tag that broke [aria-current=page]. Here's 0.5.4 with a fix!
v0.5.4v0.5.3 inadvertently introduced a regression in the <A/> tag that broke [aria-current=page]. Here's 0.5.4 with a fix!
0.5.3 release notes below:
Along with the usual set of bugfixes and small improvements, there are two noteworthy additions in this release.
#[component] macro bodyGood LSP support for proc macros is hard, because proc macros depend on parsing a stream of input into a valid Rust syntax tree, but while typing you are constantly creating a stream of new, invalid trees. This release tweaks how the #[component] macro emits code in order to enable better rust-analyzer support within the body of components.
If you've disabled rust-analyzer inside #[component] for better DX, try toggling that off and see if this is a better experience than it was before!
Apologies for any regressions this causes. Please report any issues that arise.
There is still additional work to be done to support rust-analyzer in the
view!macro. The hoped-for improvements here are solely inside the#[component]body.
<Provider/> ComponentSince 0.5.0, there've been a couple instances of bugs or confusing behavior related to the fact that context now follows the reactive graph, not the component tree (see #1986, #2038).
This release includes a <Provider/> component that provides a certain value via context only to its children:
#[component]
pub fn App() -> impl IntoView {
// each Provider will only provide the value to its children
view! {
<Provider value=1u8>
// correctly gets 1 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
<Provider value=2u8>
// correctly gets 2 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
// does not find any u8 in context
{use_context::<u8>().unwrap_or(0)}
}
}
provide_context continues working as it has since 0.5.0, and if you're using it without problems you can ignore this, or use it if you prefer to aesthetics. If you're in a situation where you need to provide multiple context values of the same type and ensure that they are scoped correctly and that siblings do not overwrite one another, use <Provider/>. If you have no idea what I mean, check the issues above for examples of the bugs this fixes.
aria-current attribute value by @alexisfontaine in https://github.com/leptos-rs/leptos/pull/2089Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.3...v0.5.4
Along with the usual set of bugfixes and small improvements, there are two noteworthy additions in this release.
v0.5.3Along with the usual set of bugfixes and small improvements, there are two noteworthy additions in this release.
#[component] macro bodyGood LSP support for proc macros is hard, because proc macros depend on parsing a stream of input into a valid Rust syntax tree, but while typing you are constantly creating a stream of new, invalid trees. This release tweaks how the #[component] macro emits code in order to enable better rust-analyzer support within the body of components.
If you've disabled rust-analyzer inside #[component] for better DX, try toggling that off and see if this is a better experience than it was before!
Apologies for any regressions this causes. Please report any issues that arise.
There is still additional work to be done to support rust-analyzer in the
view!macro. The hoped-for improvements here are solely inside the#[component]body.
<Provider/> ComponentSince 0.5.0, there've been a couple instances of bugs or confusing behavior related to the fact that context now follows the reactive graph, not the component tree (see #1986, #2038).
This release includes a <Provider/> component that provides a certain value via context only to its children:
#[component]
pub fn App() -> impl IntoView {
// each Provider will only provide the value to its children
view! {
<Provider value=1u8>
// correctly gets 1 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
<Provider value=2u8>
// correctly gets 2 from context
{use_context::<u8>().unwrap_or(0)}
</Provider>
// does not find any u8 in context
{use_context::<u8>().unwrap_or(0)}
}
}
provide_context continues working as it has since 0.5.0, and if you're using it without problems you can ignore this, or use it if you prefer to aesthetics. If you're in a situation where you need to provide multiple context values of the same type and ensure that they are scoped correctly and that siblings do not overwrite one another, use <Provider/>. If you have no idea what I mean, check the issues above for examples of the bugs this fixes.
'static bound on as_child_of_current_owner by @gbj in https://github.com/leptos-rs/leptos/pull/1955IntoView and IntoAttribute for std::fmt::Arguments improvements by @tqwewe in https://github.com/leptos-rs/leptos/pull/1947new method to Trigger by @tqwewe in https://github.com/leptos-rs/leptos/pull/1935IntoAttribute for Cow<'static, str> by @tqwewe in https://github.com/leptos-rs/leptos/pull/1945leptos_axum::build_static_routes (closes #1843) by @gbj in https://github.com/leptos-rs/leptos/pull/1855IntoAttribute for TextProp by @SleeplessOne1917 in https://github.com/leptos-rs/leptos/pull/1925login_with_token_csr_only by @gbj in https://github.com/leptos-rs/leptos/pull/1965stable to nightly by @chrisp60 in https://github.com/leptos-rs/leptos/pull/1959leptos_router::params_map! by @chrisp60 in https://github.com/leptos-rs/leptos/pull/1973leptos_server docs.rs url to latest version. by @gibbz00 in https://github.com/leptos-rs/leptos/pull/1982hackernews_js_fetch style.css path (closes #1992) by @gbj in https://github.com/leptos-rs/leptos/pull/1994<ErrorBoundary/> in a child so siblings don't collide (closes #1987) by @gbj in https://github.com/leptos-rs/leptos/pull/1991hackernews_js_fetch example by @gbj in https://github.com/leptos-rs/leptos/pull/1997APP_ENVIRONMENT variable by @gbj in https://github.com/leptos-rs/leptos/pull/2013Action::new and Action::server by @chrisp60 in https://github.com/leptos-rs/leptos/pull/1998leptos_reactive by @gbj in https://github.com/leptos-rs/leptos/pull/2014Attribute (closes #2023) by @gbj in https://github.com/leptos-rs/leptos/pull/2027create_effect for <Portal/> to avoid hydration issues (closes #2010) by @gbj in https://github.com/leptos-rs/leptos/pull/2029Default for TextProp by @blorbb in https://github.com/leptos-rs/leptos/pull/2016ActionForm examples for complex arguments by @chrisp60 in https://github.com/leptos-rs/leptos/pull/2017<Provider/> component to fix context shadowing (closes #2038) by @gbj in https://github.com/leptos-rs/leptos/pull/2040Fn in attribute (see #2023) by @gbj in https://github.com/leptos-rs/leptos/pull/2045Trigger as clean when it is re-tracked (closes #1948, #2048) by @gbj in https://github.com/leptos-rs/leptos/pull/2059#[component] macro? by @gbj in https://github.com/leptos-rs/leptos/pull/2075Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.2...v0.5.3
This has a bunch of bugfixes, small docs improvements, etc. but there are actually a *bunch* of cool new features, mostly from our growing body of con
This has a bunch of bugfixes, small docs improvements, etc. but there are actually a bunch of cool new features, mostly from our growing body of contributors. See the full changelog below, but here are some highlights (apologies if I missed anything big)
extractor() function with better APIThe extract API is awkward due to closure. This adds an extractor function which is a little more ergonomic.
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Search {
q: String,
}
// Actix
#[server]
pub async fn query_extract() -> Result<Search, ServerFnError> {
use actix_web::web::Query;
use leptos_actix::extractor;
let Query(query) = extractor().await?;
Ok(query)
}
// Axum
#[server]
pub async fn data() -> Result<Search, ServerFnError> {
use axum::extract::Query;
use leptos_axum::extractor;
let Query(query) = extractor().await?;
Ok(query)
}
<Portal/>Adds a portal component that lets you render some view mounted in a location other than where it appears in the view tree.
<Show when=show_overlay fallback=|| ()>
<div>Show</div>
<Portal mount=document().get_element_by_id("app").unwrap()>
<div style="position: fixed; z-index: 10; width: 100vw; height: 100vh; top: 0; left: 0; background: rgba(0, 0, 0, 0.8); color: white;">
<p>This is in the body element</p>
<button id="btn-hide" on:click=move |_| set_show_overlay(false)>
Close Overlay
</button>
<button id="btn-toggle" on:click=move |_| set_show_inside_overlay(!show_inside_overlay())>
Toggle inner
</button>
<Show when=show_inside_overlay fallback=|| view! { "Hidden" }>
Visible
</Show>
</div>
</Portal>
</Show>
Now that we've made all server function arguments optional, this adds in the ability to pass in one or more named arguments:
#[server(endpoint = "/path/to/my/endpoint")]
pub async fn my_server_action() -> Result<(), ServerFnError> {
Ok(())
}
#[server(encoding = "GetJson")]
pub async fn my_server_action() -> Result<(), ServerFnError> {
Ok(())
}
Adds support for directive functions, which can be used with use: in the view:
// This doesn't take an attribute value
fn my_directive(el: HtmlElement<AnyElement>) {
// do sth
}
// This requires an attribute value
fn another_directive(el: HtmlElement<AnyElement>, params: i32) {
// do sth
}
// ... in the view
view! {
<div use:my_directive></div>
<SomeComponent use:another_directive=5 />
}
slice!() macroMakes it easier to define slices. Expands to the same output as create_slice:
#[derive(Default)]
pub struct State {
count: i32,
name: String,
}
let state = create_rw_signal(State::default());
let (count, set_count) = slice!(state.count);
leptos_reactive::Trigger by @hiraginoyuki in https://github.com/leptos-rs/leptos/pull/1844extractor functions with better API than extract by @gbj in https://github.com/leptos-rs/leptos/pull/1859.try_with_untracked (closes #1880) by @gbj in https://github.com/leptos-rs/leptos/pull/1881#[must_use] to avoid accidental () rendering by @gbj in https://github.com/leptos-rs/leptos/pull/1885cargo make lint for hackernews_js_fetch by @gbj in https://github.com/leptos-rs/leptos/pull/1887ActionForm in an island by @gbj in https://github.com/leptos-rs/leptos/pull/1888on_cleanup (closes #1882) by @gbj in https://github.com/leptos-rs/leptos/pull/1889/ in splat routes (closes #1764) by @gbj in https://github.com/leptos-rs/leptos/pull/1890new method to NodeRef by @tqwewe in https://github.com/leptos-rs/leptos/pull/1896Clone requirement on SignalWith for Resource by @Xendergo in https://github.com/leptos-rs/leptos/pull/1895/ in more routes by @PianoPrinter in https://github.com/leptos-rs/leptos/pull/1900try_update() and try_set() on Resource should not panic (closes #1915) by @gbj in https://github.com/leptos-rs/leptos/pull/1916default and wasm features on leptos_axum (closes #1872) by @gbj in https://github.com/leptos-rs/leptos/pull/1883replace property to form component by @koopa1338 in https://github.com/leptos-rs/leptos/pull/1923create_slice() by @SadraMoh in https://github.com/leptos-rs/leptos/pull/1867wee_alloc to make Dependabot happy by @gbj in https://github.com/leptos-rs/leptos/pull/1938</head> tags in streaming responses (closes #1930) by @gbj in https://github.com/leptos-rs/leptos/pull/1932Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.1...v0.5.2
This is primarily a bugfix release, but it also includes a new feature: making the fallback prop on Show, Suspense, and Transition optional.
This is primarily a bugfix release, but it also includes a new feature: making the fallback prop on Show, Suspense, and Transition optional.
For 0.5 release notes in general, click here.
For view prop name (closes #1813) by @gbj in https://github.com/leptos-rs/leptos/pull/1814Copy impl for Callback by @gbj in https://github.com/leptos-rs/leptos/pull/1818intellij-rust by @sebadob in https://github.com/leptos-rs/leptos/pull/1804{..attrs} syntax (fixes #1826) by @gbj in https://github.com/leptos-rs/leptos/pull/1831with! and update! by @blorbb in https://github.com/leptos-rs/leptos/pull/1836generate_route_list if you immediately dispatch an action (closes #1832) by @gbj in https://github.com/leptos-rs/leptos/pull/1853clippy "needless lifetimes" warning (closes #1825) by @gbj in https://github.com/leptos-rs/leptos/pull/1852Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.0...v0.5.1
This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.
v0.5.0ScopeThis long-awaited release changes the nature of the reactive system by removing the entire concept of explicit Scope and the ubiquitous cx variable.
The primary impetus behind this change is that it increases the correctness of the behavior of the reactive system, and fixes several persistent issues.
<details>
<summary>Click here for more details.</summary>
In order to provide signals that implement Copy are are 'static and are therefore easy to use with closures and event listeners in 100% safe Rust, Leptos allocates memory for signals, memos, and effects in an arena. This raises the question: When is it safe to deallocate/dispose of these signals?
From 0.0 to 0.4, Leptos allocated signals in a dedicated Scope, which was ubiquitous in APIs. This had several drawbacks
Scope argument on many functions prevented us from implementing many traits that could not take an additional argument on signals, like From, Serialize/Deserialize.Scope was stored in a variable that was passed around, meaning that the “wrong” scope could be passed into functions (most frequently Resource::read()). If, for example, a derived signal or memo read from a resource in the component body, and was called under a Suspense lower in the tree, the Scope used would be from the parent component, not the Suspense. This was just wrong, but involved wrapping the function in another closure to pass in the correct Scope.Scopes were manually created and disposed, or in which on_cleanup was never called. (See #802 and #918 for more background.)The solution to this problem was to do what I should have been doing a year ago, and merge the memory allocation function of Scope into the reactive graph itself, which already handles reactive unsubscriptions and cleanup. JavaScript doesn’t deal with memory management, but SolidJS handles its onCleanup through a concept of reactive ownership; disposing of memory for our signals is really just a case of cleanup on an effect or memo rerunning.
Essentially, rather than being owned by a Scope every signal, effect, or memo is now owned by its parent effect or memo. (If it’s in an untrack, there’s no reactive observer but the reactive owner remains.) Every time an effect or memo reruns, it disposes of everything “beneath” it in the tree. This makes sense: for a signal to be owned by an effect/memo, it must have been created during the previous run, and will be recreated as needed during the next run, so this is the perfect time to dispose of it.
</details>
It also has the fairly large benefit of removing the need to pass cx or Scope variables around at all, and allowing the implementation of a bunch of different traits on the various signal types.
Now that we don't need an extra Scope argument to construct them, many of the signal types now implement Serialize/Deserialize directly, as well as From<T>. This should make it significantly easier to do things like "reactively serialize a nested data structure in a create_effect" — this removed literally dozens of lines of serialization/deserialization logic and a custom DTO from the todomvc example. Serializing a signal simply serializes its value, in a reactive way; deserializing into a signal creates a new signal containing that deserialized value.
Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope, => (empty string)cx: Scope => (empty string)cx, => (empty string)(cx) => ()|cx| => ||Scope, => (empty string)Scope => (empty string) as needed|_, _| that become |_| or |_| that become ||, particularly for the fallback props on <Show/> and <ErrorBoundary/>.Basically, there is no longer a Scope type, and anything that used to take it can simply be deleted.
For the 5%: if you were doing tricky things like storing a Scope somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current() somewhere and then later using it in with_owner(owner, move || { /* ... */ }). If you have issues with this kind of migration, please let me know by opening an issue or discussion thread and we can work through the migration.
This release contains an initial, but very functional, implementation of the “islands architecture” for Leptos.
This adds an experimental-islands feature that opts you into a rendering mode that's different from the traditional server-rendered/client-hydrated model described here, in which the entire page requested is rendered to HTML on the server for the first request, and then runs on the client to hydrate this server-rendered HTML, and subsequent navigations take place by rendering pages in the browser.
The
experimental-inexperimental-islandsmeans “parts of this API may need to change, and I won’t guarantee that its APIs won’t break during 0.5,” but I have no reasons to believe there are significant issues, and I have no planned API changes at present.
With this islands feature on, components are only rendered on the server, by default. Navigations follow the traditional/multi-page-app (MPA) style of navigating by fetching a new HTML page from the server. The name "islands" comes from the concept of the "islands architecture," in which you opt into small “islands” of interactivity in an “ocean” of server-rendered, non-interactive HTML.
This allows reducing the WASM binary size by a lot (say ~80% for a typical demo app), making the time-to-interactive for a page load much faster. It also allows you to treat most components as “server components” and use server-only APIs, because those plain components will never need to be rendered in the browser.
I still need to write some guide-style docs for the book, but I tried to put a pretty good amount of information in the PR, which you should read if you’re interested in this topic or in trying out islands.
There’s significant additional exploration that will take place in this direction. Expect a longer treatment in an upcoming updated roadmap posted as a pinned issue.
This release includes some preliminary work on building static site rendering directly into the framework, mostly as part of leptos_router and the server integrations. Static site generation is built off of two key components, a new <StaticRoute /> component and the leptos_router::build_static_routes function.
StaticRoute defines a new static route. In order to be a static route, all parent routes must be static in order to ensure that complete URLs can be built as static pages. A “static route” means that a page can be rendered as a complete HTML page that is then cached and served on subsequent requests, rather than dynamically rendered, significantly reducing the server’s workload per request.
StaticRoute takes a path and view (like any Route) and a static_params prop. This is a function that returns a Future, which is used to provide a map of all the possible values for each route param. These static params are generated on the server. This means you can do something like call a #[server] function or access a database or the server filesystem. For example, if you have a /post/:id path, you might query the database for a list of all blog posts and use that to generate a set of possible params.
StaticRoute can be given an optional mode: StaticMode::Upfront (the default) or StaticMode::Incremental. Upfront means that all given routes will be generated when you call build_static_routes, and a 404 will be returned for any other pages. Incremental means that all the options you give in static_params will be generated up front, and additional pages will be generated when first requested and then cached.
Where our routes are defined, we can include a StaticRoute:
view! {
<Routes>
<StaticRoute
mode=StaticMode::Incremental
path="/incr/:id"
view=StaticIdView
static_params=move || Box::pin(async move {
let mut map = StaticParamsMap::default();
map.insert("id".to_string(), vec![(1).to_string(), (2).to_string()]);
map
})
/>
</Routes>
}
In main.rs, we build the static routes for the site on server startup:
let (routes, static_data_map) = generate_route_list_with_ssg(App);
build_static_routes(&conf.leptos_options, App, &routes, &static_data_map)
.await
.unwrap();
There is additional work needed here as far as providing examples, and building out the story for things like invalidation (when to rebuild a page) and build hooks (when to build additional pages).
attr: on components, and spreading attributesMakes it much easier to pass some set of attributes to be given to a component (with attr: passed into a #[prop(attrs)] prop), and then to spread them onto an element with {..attrs} syntax.
#[component]
pub fn App() -> impl IntoView {
view! {
<Input attr:value="hello" attr:label="foo" />
<Input attr:type="number" attr:value="0" />
}
}
#[component]
pub fn Input(
#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
view! {
<input {..attrs} />
<pre>{format!("{attrs2:#?}")}</pre>
}
}
Newly added support for syntax that identifies a generic type for a component in the view
#[component]
pub fn GenericComponent<S>(#[prop(optional)] ty: PhantomData<S>) -> impl IntoView {
std::any::type_name::<S>()
}
#[component]
pub fn App() -> impl IntoView {
view! {
<GenericComponent<String>/>
<GenericComponent<usize>/>
<GenericComponent<i32>/>
}
}
Callback typesThis release includes a Callback type that makes it much easier to pass optional callbacks as component props, which was previously not possible with generically-typed callbacks.
#[component]
fn MyComponent(
#[prop(optional, into)] render_number: Option<Callback<(i32, i32), String>>,
) -> impl IntoView {
render_number.map(|render_nummber| {
view! {
<div>
// function call syntax works on nightly
{render_number((42, 37))}
// does the same thing
{render_number.call((42, 37))}
</div>
}
})
}
#[component]
pub fn App() -> impl IntoView {
view! {
<MyComponent render_number=|(x, y)| format!("x: {x} - y: {y}")/>
}
}
with!() and update!() macrosNested .with() calls are a pain. Now you can do
let (first, _) = create_signal("Bob".to_string());
let (middle, _) = create_signal("J.".to_string());
let (last, _) = create_signal("Smith".to_string());
let name = move || with!(|first, middle, last| format!("{first} {middle} {last}"));
instead of
let name = move || {
first.with(|first| {
middle.with(|middle| last.with(|last| format!("{first} {middle} {last}")))
})
};
This framework's origins as a Rust port of SolidJS mean we've inherited some functional-JS-isms. Combined with the need to pass cx everywhere prior to 0.5 this has tended to mean we've gone with create_ and so on rather than Rusty ::new(). This simply adds a few Rustier constructors like
let count = RwSignal::new(0);
let double_count = Memo::new(move |_| count() * 2);
#[server] ArgumentsAll arguments to #[server]are now optional: change default prefix to /api and default to generating a PascalCase type name from the function name
// before
#[server(MyName, "/api")]
pub async fn my_name() /* ... */
// after
#[server]
pub async fn my_name /* ... */
We have adapted the Axum integration to be usable when running inside JS-hosted WASM environments (Deno Deploy, Cloudflare Workers, etc.) This can be done by disabling default-features on axum and leptos_axum, using the axum-js-fetch library, and enabling the wasm feature on leptos_axum.
leptos_axum = { version = "0.5", default-features = false, optional = true }
axum = { version = "0.6", default-features = false, optional = true }
axum-js-fetch = { version = "0.2", optional = true }
# ...
[features]
default = ["csr"]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = [
"dep:axum",
"dep:axum-js-fetch",
"leptos_axum/wasm",
# ...
]
There's a full Hackernews example in the repo that runs within Deno.
Resource APIs. Resources now follow the same API as other signals: .get() and .with() apply to the current value (which may be None). This means the old .with(), which was only called when the resource had resolved, is now .map(). There's also a new .and_then() method which can be called to deeply map over resources that return Result, like server functions. The goal of these methods is to reduce the amount of boilerplate mapping necessary with resources previously. Check out the Resource docs for more info.create_effect now returns an Effect struct. This exists mostly so you can .dispose() it early if you need. (This may require adding some missing semicolons, as create_effect no longer returns ().)create_effect’s first run is now scheduled on the next tick, using queueMicrotask. In other words, create_effect runs after your component returns a view, not immediately as the component runs. This removes most of the cases in which nesting request_animation_frame inside a create_effect had been necessary.impl Into<Cow<'static, str>> now take impl Into<Oco<'static, str>>. Oco (Owned Clones Once) is a new type designed to minimized the cost of cloning immutable string types, like the ones used in the View. Essentially this makes it cheaper to clone text nodes and attribute nodes within the renderer, without imposing an additional cost when you don't need to. This shouldn't require changes to your application in most cases of normal usage. (See #1480 for additional discussion.)leptos_axum::generate_route_list()This function is no longer async. This means removing a single .await from main.rs in any Leptos-Axum app, but brings the API of the Axum (and Viz) integrations into line with the Actix one, and unlocks the use of this function in some non-async settings where it was desired.
<For/> prop view renamed childrenThe name of the function that renders each row of data to a view is now children rather than view. This means that the view can now be included inline, without needing to break out of the markup into another closure and view! macro invocation.
In other words,
let (data, set_data) = create_signal(vec![0, 1, 2]);
view! {
<For
each=data
key=|n| *n
// stores the item in each row in a variable named `data`
let:data
>
<p>{data}</p>
</For>
}
is the same as
let (data, set_data) = create_signal(vec![0, 1, 2]);
view! {
<For
each=data
key=|n| *n
children=|data| view! { <p>{data}</p> }
/>
}
which replaces
let (data, set_data) = create_signal(vec![0, 1, 2]);
view! {
<For
each=data
key=|n| *n
view=|data| view! { <p>{data}</p> }
/>
}
use_navigate navigate function no longer returns a valueThe navigate("path", options) call now uses request_animation_frame internally to delay a tick before navigating, which solves a few odd edge cases having to do with redirecting immediately and the timing of reactive system cleanups. This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.
If you were relying on the Result<_, _> here and want access to it, let me know and we can bring back a version that has it. Otherwise, this shouldn't really require any changes to your app.
window_event_listener and friends now return a handle for removalThis one was just an API oversight originally, again taking advantage of the semver update. window_event_listener and its untyped version now return a WindowListenerHandle with a .remove() method that can be called explicitly to remove that event, for example in an on_cleanup.
#[component]
fn TypingPage() -> impl IntoView {
let handle = window_event_listener(ev::keypress, |ev| {
/* do something */
});
on_cleanup(move || handle.remove());
}
use_context no longer works inside event listeners, inside spawn_local, etc. Use use_context inside the body of a component and move the context data into those other closures. (See here for more details.)bind: has been renamed let:, which makes more sense for variable binding. (This applies to components like Await and now For, which take arguments in their children.)Transition’s set_pending prop now applies #[prop(into)], which means it can take any signal setter. If you were doing something already like set_pending=something.into() the compiler will now get confused; just remove that .into().create_effect’s first run is now scheduled on the next tick, using queueMicrotask. In other words, create_effect runs after your component returns a view, not immediately as the component runs. (Listing this as both a feature and a breaking change, as it is a behavior change!)log!, warn!, and error! macros have been moved into a separate logging module to avoid naming conflicts with the log and tracing crates. You can import them as use leptos::logging::*; if desired.Value type rather than a generic (see #1578)Resource APIs: the function formerly known as .with() is now .map(), and .read() is now .get() to match other signals.Scope-based ownership to reactive ownership by @gbj in https://github.com/leptos-rs/leptos/pull/918.refetch() (occurs in e.g., async blocks in actions) by @gbj in https://github.com/leptos-rs/leptos/pull/1576render_to_string_async by @gbj in https://github.com/leptos-rs/leptos/pull/1574Fn traits for resources on nightly by @gbj in https://github.com/leptos-rs/leptos/pull/1587typed-builder 0.16 (closes #1455) by @gbj in https://github.com/leptos-rs/leptos/pull/1590Oco (Owned Clones Once) smart pointer by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1480get_property by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1638logging module to avoid name conflicts with log and tracing by @gbj in https://github.com/leptos-rs/leptos/pull/1658Rc backed ChildrenFn by @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1669extract_with_state function by @gbj in https://github.com/leptos-rs/leptos/pull/1683mount_to_body in CSR mode by @gbj in https://github.com/leptos-rs/leptos/pull/1688#[island] macro by @gbj in https://github.com/leptos-rs/leptos/pull/1691IntoView for Rc<dyn Fn() -> impl IntoView> by @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1698From<HtmlElement<El>> for HtmlElement<AnyElement> by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1700component macro by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1696move on with! macros by @blorbb in https://github.com/leptos-rs/leptos/pull/1717Serialize and Deserialize for Oco<_> by @gbj in https://github.com/leptos-rs/leptos/pull/1720#[prop(default = ...)] as in Optional Props (closes #1710) by @gbj in https://github.com/leptos-rs/leptos/pull/1721Resource::with() (closes #1711) by @gbj in https://github.com/leptos-rs/leptos/pull/1726create_effect internally with create_isomorphic_effect (closes #1709) by @gbj in https://github.com/leptos-rs/leptos/pull/1723LeptosRoutes by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1729attr: syntax rather than AdditionalAttributes by @gbj in https://github.com/leptos-rs/leptos/pull/1728Resource::with() pt. 2 — (closes #1742 without reopening #1711) by @gbj in https://github.com/leptos-rs/leptos/pull/1750Resource::with() (pt. 3!) — closes #1751 without breaking #1742 or #1711 by @gbj in https://github.com/leptos-rs/leptos/pull/1752Transition set_pending use #[prop(into)] by @gbj in https://github.com/leptos-rs/leptos/pull/1746use_context between islands by @gbj in https://github.com/leptos-rs/leptos/pull/1747Oco cloning by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1749view! macro if you use cx, by @gbj in https://github.com/leptos-rs/leptos/pull/1772create_local_resource in the browser by @gbj in https://github.com/leptos-rs/leptos/pull/1777Show docs reference to scope by @gbj in https://github.com/leptos-rs/leptos/pull/1779let: instead of bind: by @gbj in https://github.com/leptos-rs/leptos/pull/1774For by switching to children and bind: by @gbj in https://github.com/leptos-rs/leptos/pull/1773toml feature for the config dependency by @messense in https://github.com/leptos-rs/leptos/pull/1788From<Fn() -> T> for Signal<T> by @gbj in https://github.com/leptos-rs/leptos/pull/1801Suspense when a resource loads immediately (closes #1805) by @gbj in https://github.com/leptos-rs/leptos/pull/1809ScopedFuture by @gbj in https://github.com/leptos-rs/leptos/pull/1810Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.9...v0.5.0
Most significant breaking change you might notice is that generate_route_list in Axum is no longer async and doesn't need .await, as is already true f…
Most significant breaking change you might notice is that generate_route_list in Axum is no longer async and doesn't need .await, as is already true for Actix.
Big features including static site generation included here, but I will wait for an actual release to write up notes because it's Friday afternoon!
Callback cloning by @lpotthast in https://github.com/leptos-rs/leptos/pull/1744Resource::with() pt. 2 — (closes #1742 without reopening #1711) by @gbj in https://github.com/leptos-rs/leptos/pull/1750Resource::with() (pt. 3!) — closes #1751 without breaking #1742 or #1711 by @gbj in https://github.com/leptos-rs/leptos/pull/1752Transition set_pending use #[prop(into)] by @gbj in https://github.com/leptos-rs/leptos/pull/1746use_context between islands by @gbj in https://github.com/leptos-rs/leptos/pull/1747Oco cloning by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1749view! macro if you use cx, by @gbj in https://github.com/leptos-rs/leptos/pull/1772Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.0-rc2...v0.5.0-rc3
docs: update possibly deprecated docs for component macro by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1696
IntoView for Rc<dyn Fn() -> impl IntoView> by @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1698From<HtmlElement<El>> for HtmlElement<AnyElement> by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1700component macro by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1696move on with! macros by @blorbb in https://github.com/leptos-rs/leptos/pull/1717Serialize and Deserialize for Oco<_> by @gbj in https://github.com/leptos-rs/leptos/pull/1720#[prop(default = ...)] as in Optional Props (closes #1710) by @gbj in https://github.com/leptos-rs/leptos/pull/1721Resource::with() (closes #1711) by @gbj in https://github.com/leptos-rs/leptos/pull/1726create_effect internally with create_isomorphic_effect (closes #1709) by @gbj in https://github.com/leptos-rs/leptos/pull/1723LeptosRoutes by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1729attr: syntax rather than AdditionalAttributes by @gbj in https://github.com/leptos-rs/leptos/pull/1728Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.0-rc1...v0.5.0-rc2
I'm planning on releasing 0.5.0 proper toward the end of this week. However, we've continued having some really good new features and some changes, so
I'm planning on releasing 0.5.0 proper toward the end of this week. However, we've continued having some really good new features and some changes, so I want to give it some additional time for testing rather than rushing and breaking things.
For overall 0.5.0 changes, see here.
attr: on components, and spreading attributesMakes it much easier to pass some set of attributes to be given to a component (with attr: passed into a #[prop(attrs)] prop), and then to spread them onto an element with {..attrs} syntax.
#[component]
pub fn App() -> impl IntoView {
view! {
<Input attr:value="hello" attr:label="foo" />
<Input attr:type="number" attr:value="0" />
}
}
#[component]
pub fn Input(
#[prop(attrs)] attrs: Vec<(&'static str, Attribute)>,
) -> impl IntoView {
view! {
<input {..attrs} />
<pre>{format!("{attrs2:#?}")}</pre>
}
}
Newly added support for syntax that identifies a generic type for a component in the view
#[component]
pub fn GenericComponent<S>(#[prop(optional)] ty: PhantomData<S>) -> impl IntoView {
std::any::type_name::<S>()
}
#[component]
pub fn App() -> impl IntoView {
view! {
<GenericComponent<String>/>
<GenericComponent<usize>/>
<GenericComponent<i32>/>
}
}
Callback typesThese make it easier to add things like optional callback functions to components.
#[component]
pub fn App() -> impl IntoView {
view! {
<ShowOptFall when=|| { 5 < 3 } fallback=|_| view! { <p>"YES"</p> }>
<p>"NO"</p>
</ShowOptFall>
<ShowOptFall when=|| { 5 < 3 }>
<p>"NO"</p>
</ShowOptFall>
<ShowOptFall when=||{ 5 > 3 }>
<p>"YES"</p>
</ShowOptFall>
}
}
#[component]
pub fn ShowOptFall<W>(
/// The components Show wraps
children: Box<dyn Fn() -> Fragment>,
/// A closure that returns a bool that determines whether this thing runs
when: W,
/// A closure that returns what gets rendered if the when statement is false
#[prop(optional, into)]
fallback: Option<ViewCallback<()>>,
) -> impl IntoView
where
W: Fn() -> bool + 'static,
{
let memoized_when = create_memo(move |_| when());
move || match memoized_when.get() {
true => children().into_view(),
false => match fallback.as_ref() {
Some(fallback) => fallback.call(()).into_view(),
None => ().into_view(),
},
}
}
with!() and update!() macrosNested .withI() calls are a pain. Now you can do
let (first, _) = create_signal("Bob".to_string());
let (middle, _) = create_signal("J.".to_string());
let (last, _) = create_signal("Smith".to_string());
let name = move || with!(|first, middle, last| format!("{first} {middle} {last}"));
instead of
let name = move || {
first.with(|first| {
middle.with(|middle| last.with(|last| format!("{first} {middle} {last}")))
})
};
This framework's origins as a Rust port of SolidJS mean we've inherited some functional-JS-isms. Combined with the need to pass cx everywhere prior to 0.5 this has tended to mean we've gone with create_ and so on rather than Rusty ::new(). This simply adds a few Rustier constructors like
let count = RwSignal::new(0);
let double_count = Memo::new(move |_| count() * 2);
.derived_signal() and .mapped_signal_setter() to the more idiomatic .into_signal() and .into_signal_setter()Suspense is ready yet or not in order to avoid over-re-rendering. Shouldn't break your app, but if something weird happens let me know.create_effect so that it runs a tick after it is created, which solves a number of timing issues with effects that had previously led to create_effect(move || request_animation_frame(move || /* */))get_property by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1638logging module to avoid name conflicts with log and tracing by @gbj in https://github.com/leptos-rs/leptos/pull/1658Rc backed ChildrenFn by @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1669extract_with_state function by @gbj in https://github.com/leptos-rs/leptos/pull/1683mount_to_body in CSR mode by @gbj in https://github.com/leptos-rs/leptos/pull/1688#[island] macro by @gbj in https://github.com/leptos-rs/leptos/pull/1691Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.5.0-beta...v0.5.0-rc1
I'm expecting to release 0.5.0 itself in the next couple weeks, there have just been a couple other small but breaking changes proposed that are worki…
Just another beta release. I'm expecting to release 0.5.0 itself in the next couple weeks, there have just been a couple other small but breaking changes proposed that are working their way through, and I'd rather delay a bit than rush it and be stuck.
0.5.0-beta2 reflects the current state of the main branch. The v0.5.0 in General section is copied and pasted from previous releases. New this Release reflects changes since 0.5.0-beta (I think?).
#[server] optional: change default prefix to /api and default to generating a PascalCase type name from the function name// before
#[server(MyName, "/api")]
pub async fn my_name() /* ... */
// after
#[server]
pub async fn my_name /* ... */
create_effect now returns an Effect struct. This exists mostly so you can .dispose() it early if you need. (This may require adding some missing semicolons, as create_effect no longer returns ().)Value type rather than a generic (see #1578)impl Into<Cow<'static, str>> now take impl Into<Oco<'static, str>>. Oco (Owned Clones Once) is a new type designed to minimized the cost of cloning immutable string types, like the ones used in the View. Essentially this makes it cheaper to clone text nodes and attribute nodes within the renderer, without imposing an additional cost when you don't need to. This shouldn't require changes to your application in most cases of normal usage. (See #1480 for additional discussion.)v0.5.0 in GeneralThis long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related to the manual use of cx/Scope and could create memory leaks. (See #918 for details)
It also has the fairly large DX change (improvement?) of removing the need to pass cx or Scope variables around at all.
Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope, => (empty string)cx: Scope => (empty string)cx, => (empty string)(cx) => ()|cx| => ||Scope, => (empty string)Scope => (empty string) as needed|_, _| that become |_| or |_| that become ||, particularly for the fallback props on <Show/> and <ErrorBoundary/>Basically, there is no longer a Scope type, and anything that used to take it can simply be deleted.
For the 5%: if you were doing tricky things like storing a Scope somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current() somewhere and then later using it in with_owner(owner, move || { /* ... */ }).
There are no other big conceptual or API changes in this update: essentially all the same reactive, templating, and component concepts should still apply, just without cx.
Scope-based ownership to reactive ownership by @gbj in https://github.com/leptos-rs/leptos/pull/918.refetch() (occurs in e.g., async blocks in actions) by @gbj in https://github.com/leptos-rs/leptos/pull/1576render_to_string_async by @gbj in https://github.com/leptos-rs/leptos/pull/1574Fn traits for resources on nightly by @gbj in https://github.com/leptos-rs/leptos/pull/1587typed-builder 0.16 (closes #1455) by @gbj in https://github.com/leptos-rs/leptos/pull/1590Oco (Owned Clones Once) smart pointer by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1480Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.9...0.5.0-beta2
This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.
This beta release brings us closer to 0.5.0 proper.
The big changes are dropping cx/Scope entirely. I've copied and pasted the 0.5.0-alpha release notes below for reference, along with a few notes about other changes since the alpha release. A few other changes (#1480, #1485) will be incorporated once it's ready for release.
v0.5.0 in GeneralThis long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related to the manual use of cx/Scope and could create memory leaks. (See #918 for details)
It also has the fairly large DX change (improvement?) of removing the need to pass cx or Scope variables around at all.
Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope, => (empty string)cx: Scope => (empty string)cx, => (empty string)(cx) => ()|cx| => ||Scope, => (empty string)Scope => (empty string) as needed|_, _| that become |_| or |_| that become ||, particularly for the fallback props on <Show/> and <ErrorBoundary/>Basically, there is no longer a Scope type, and anything that used to take it can simply be deleted.
For the 5%: if you were doing tricky things like storing a Scope somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current() somewhere and then later using it in with_owner(owner, move || { /* ... */ }).
There are no other big conceptual or API changes in this update: essentially all the same reactive, templating, and component concepts should still apply, just without cx.
Now that we don't need an extra Scope argument to construct them, many of the signal types now implement Serialize/Deserialize directly, as well as From<T>. This should make it significantly easier to do things like "reactively serialize a nested data structure in a create_effect" — this removed literally dozens of lines of serialization/deserialization logic and a custom DTO from the todomvc example. Serializing a signal simply serializes its value, in a reactive way; deserializing into a signal creates a new signal containing that deserialized value.
use_navigate navigate function no longer returns a valueThe navigate("path", options) call now uses request_animation_frame internally to delay a tick before navigating, which solves a few odd edge cases having to do with redirecting immediately and the timing of reactive system cleanups. This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.
If you were relying on the Result<_, _> here and want access to it, let me know and we can bring back a version that has it. Otherwise, this shouldn't really require any changes to your app.
window_event_listener and friends now return a handle for removalThis one was just an API oversight originally, again taking advantage of the semver update. window_event_listener and its untyped version now return a WindowListenerHandle with a .remove() method that can be called explicitly to remove that event, for example in an on_cleanup.
Again, shouldn't require meaningful changes.
#[component]
fn TypingPage() -> impl IntoView {
let handle = window_event_listener(ev::keypress, |ev| {
/* do something */
});
on_cleanup(move || handle.remove());
}
leptosfmt and cargo leptos --hot-reload, which assume that the view! needs a cx,, will probably not work as intended and will need to be updated.
Any other ecosystem libraries that depend on Leptos 0.4 won't work, of course.
Nothing published for this version
This long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related t
This long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related to the manual use of cx/Scope and could create memory leaks. (See #918 for details)
It also has the fairly large DX change (improvement?) of removing the need to pass cx or Scope variables around at all.
Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope, => (empty string)cx: Scope => (empty string)cx, => (empty string)(cx) => ()|cx| => ||Scope, => (empty string)Scope => (empty string) as needed|_, _| that become |_| or |_| that become ||, particularly for the fallback props on <Show/> and <ErrorBoundary/>Basically, there is no longer a Scope type, and anything that used to take it can simply be deleted.
For the 5%: if you were doing tricky things like storing a Scope somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current() somewhere and then later using it in with_owner(owner, move || { /* ... */ }).
There are no other big conceptual or API changes in this update: essentially all the same reactive, templating, and component concepts should still apply, just without cx.
leptosfmt and cargo leptos --hot-reload, which assume that the view! needs a cx,, will probably not work as intended and will need to be updated.
Any other ecosystem libraries that depend on Leptos 0.4 won't work, of course.
This needs pretty extensive testing with real apps. It passes our test suite and the examples seem to work fine, but I'm sure there are bugs out there. Help find them! I've created a discussion linked to these release notes that you can use for feedback or to help track down bugs.
Nothing published for this version
I'm getting ready to merge the effect-cleanups branch into main, as well as merging #1480 and #1485 in preparation for the release of 0.5.0, so this r
I'm getting ready to merge the effect-cleanups branch into main, as well as merging #1480 and #1485 in preparation for the release of 0.5.0, so this release is just a "final state of 0.4.x" release before the main branch switches over from being 0.4 to 0.5. It does include some notable work, though:
view macro with snapshot testingtracing supportcopy feature is now only enabled if nightly feature is enabled by @thestarmaker in https://github.com/leptos-rs/leptos/pull/1503 (closes #1382) by @gbj in https://github.com/leptos-rs/leptos/pull/1507create_query_signal by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1508use_navigate to router docs in guide by @gbj in https://github.com/leptos-rs/leptos/pull/1524NavigateOptions docs by @gbj in https://github.com/leptos-rs/leptos/pull/1525prop:value by @gbj in https://github.com/leptos-rs/leptos/pull/1526cargo doc by @martinfrances107 in https://github.com/leptos-rs/leptos/pull/1539Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.8...v0.4.9
There was a log erroneously left in 0.4.7, so I rereleased as 0.4.8. Notes for 0.4.7 below.
There was a log erroneously left in 0.4.7, so I rereleased as 0.4.8. Notes for 0.4.7 below.
This is mostly a bug-fix release with a few small features. There will probably be one or two more patch releases before 0.5.0.
mut in component propsThis didn't work before; now it does:
#[component]
fn TestMutCallback<'a, F>(
cx: Scope,
mut callback: F,
value: &'a str,
) -> impl IntoView
where
F: FnMut(u32) + 'static,
{
MaybeProp typeMaybeProp is essentially a wrapper for Option<MaybeSignal<Option<T>>> with a nicer API. This is useful for something like a component library, where you want to give a user the maximum flexibility in the types they give to props while still checking that they're the appropriate T.
This allows you to define optional props that
Signal<Option<T>>)Implementing
From<_>for a plainSignal<T>type here is possible, but depends on the changes in0.5.0, so I'll add it for that release.
#[component]
pub fn App(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 5);
view! { cx,
<TakesMaybeProp/>
<TakesMaybeProp maybe=42/>
<TakesMaybeProp maybe=Signal::derive(cx, move || Some(count.get()))/>
}
}
#[component]
pub fn TakesMaybeProp(cx: Scope, #[prop(optional, into)] maybe: MaybeProp<i32>) -> impl IntoView {
// .get() gives you `Option<T>`, replacing `self.as_ref().and_then(|n| n.get())`
let value: Option<i32> = maybe.get();
// .with() takes a plain `&T`; returns `None` if the prop isn't present or the inner value is None
let plus_one = maybe.with(|n: &i32| n + 1);
view! { cx,
<p>{maybe}</p>
}
}
This is mostly a bug-fix release with a few small features. There will probably be one or two more patch releases before 0.5.0.
This is mostly a bug-fix release with a few small features. There will probably be one or two more patch releases before 0.5.0.
mut in component propsThis didn't work before; now it does:
#[component]
fn TestMutCallback<'a, F>(
cx: Scope,
mut callback: F,
value: &'a str,
) -> impl IntoView
where
F: FnMut(u32) + 'static,
{
MaybeProp typeMaybeProp is essentially a wrapper for Option<MaybeSignal<Option<T>>> with a nicer API. This is useful for something like a component library, where you want to give a user the maximum flexibility in the types they give to props while still checking that they're the appropriate T.
This allows you to define optional props that
Signal<Option<T>>)Implementing
From<_>for a plainSignal<T>type here is possible, but depends on the changes in0.5.0, so I'll add it for that release.
#[component]
pub fn App(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 5);
view! { cx,
<TakesMaybeProp/>
<TakesMaybeProp maybe=42/>
<TakesMaybeProp maybe=Signal::derive(cx, move || Some(count.get()))/>
}
}
#[component]
pub fn TakesMaybeProp(cx: Scope, #[prop(optional, into)] maybe: MaybeProp<i32>) -> impl IntoView {
// .get() gives you `Option<T>`, replacing `self.as_ref().and_then(|n| n.get())`
let value: Option<i32> = maybe.get();
// .with() takes a plain `&T`; returns `None` if the prop isn't present or the inner value is None
let plus_one = maybe.with(|n: &i32| n + 1);
view! { cx,
<p>{maybe}</p>
}
}
<Each/> in debug mode (closes #1168) by @gbj in https://github.com/leptos-rs/leptos/pull/1436MaybeProp type by @gbj in https://github.com/leptos-rs/leptos/pull/1443mut in component props and suppress "needless lifetime" warning (closes #1458) by @gbj in https://github.com/leptos-rs/leptos/pull/1459AnimatedShow - possible panic on cleanup by @sebadob in https://github.com/leptos-rs/leptos/pull/1464ServerFnErrorErr by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1477Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.6...v.0.4.7
Improved support for a wider set of valid HTML attribute names (like class:something-500) not previously supported (@vldm in https://github.com/leptos
class:something-500) not previously supported (@vldm in https://github.com/leptos-rs/leptos/pull/1416)create_query_signal (@tqwewe in https://github.com/leptos-rs/leptos/pull/1377)<AnimatedShow> component (closes #1370) (@sebadob in https://github.com/leptos-rs/leptos/pull/1386)Resource::dispose() by @gbj in https://github.com/leptos-rs/leptos/pull/1393TryFrom for Url by @tqwewe in https://github.com/leptos-rs/leptos/pull/1376create_memo to reflect laziness by @gbj in https://github.com/leptos-rs/leptos/pull/1388<form> by @gbj in https://github.com/leptos-rs/leptos/pull/1398<Route/> views when possible by @gbj in https://github.com/leptos-rs/leptos/pull/1375RawText/unquoted text nodes in SSR (closes #1384) by @gbj in https://github.com/leptos-rs/leptos/pull/1407svg::, math::, and use_ (closes #1403) by @gbj in https://github.com/leptos-rs/leptos/pull/1406<use_/> as typed top-level element in view by @gbj in https://github.com/leptos-rs/leptos/pull/1410incorrect_clone_impl_on_copy_type (closes #1401) by @gbj in https://github.com/leptos-rs/leptos/pull/1418<title> correctly when navigating between pages by @gbj in https://github.com/leptos-rs/leptos/pull/1428Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.5...v0.4.6
I've gotten back into a regular rhythm of patch releases pulling in some of the smaller bugfixes, but haven't had time to write release notes for each
I've gotten back into a regular rhythm of patch releases pulling in some of the smaller bugfixes, but haven't had time to write release notes for each one. I should just auto-generate them, I suppose—sorry about that!
Anyway here's a quick summary of the new features included in the past few releases. The full changelog below includes various bugfixes, chores, and updates to the docs as well.
cargo leptos watch --hot-reloadleptos_axum::extract_with_state to support extractors that use a State, if it's been provided via context in a custom handlerwatch function, which functions as a more configurable create_effect, including the ability to explicitly list dependencies, stop listening to them, whether to run immediately or lazily, etc.use_nonce and the nonce feature<For/> diffing algorithm that both fixes a number of correctness issues/edge cases in <For/> and drops ~10kb from the WASM binaryBasically, a bunch of small but really useful changes, and about a hundred bugfixes.
I also just want to give a shout-out to @agilarity, who's become one of the top contributors to the library through a very helpful focus on CI and testing. If you're ever looking for a great model of how to test a Leptos frontend app, the counters_stable example now features two complete test suites, one in JS using Playwright and one written in Rust using wasm_bindgen_test. This has been a huge amount of very impressive work.
v0.4.0 by @gbj in https://github.com/leptos-rs/leptos/pull/1250cargo fmt by @gbj in https://github.com/leptos-rs/leptos/pull/1266HtmlElement::dyn_classes() when adding classes by @gbj in https://github.com/leptos-rs/leptos/pull/1265<For/> that has a previous sibling in release mode (fixes #1258) by @gbj in https://github.com/leptos-rs/leptos/pull/1267dyn_classes by @gbj in https://github.com/leptos-rs/leptos/pull/1270State(_) extractors by @gbj in https://github.com/leptos-rs/leptos/pull/1272<For/> hydration (closes #1279) by @gbj in https://github.com/leptos-rs/leptos/pull/1281<Redirect/> by @gbj in https://github.com/leptos-rs/leptos/pull/1280once_cell::OnceCell rather than std::OnceCell by @gbj in https://github.com/leptos-rs/leptos/pull/1288mdbook in flake by @gbj in https://github.com/leptos-rs/leptos/pull/1299View by @gbj in https://github.com/leptos-rs/leptos/pull/1302<Show/> example by @gbj in https://github.com/leptos-rs/leptos/pull/1303<ActionForm/> should check origin correctly before doing a full-page refresh by @gbj in https://github.com/leptos-rs/leptos/pull/1304cargo make tasks by @agilarity in https://github.com/leptos-rs/leptos/pull/1320<ActionForm/> should set value even if redirected by @gbj in https://github.com/leptos-rs/leptos/pull/1321redirect() duplicate Location headers by @gbj in https://github.com/leptos-rs/leptos/pull/1326#[must_use] on views by @gbj in https://github.com/leptos-rs/leptos/pull/1329nightly in "Getting Started" by @gbj in https://github.com/leptos-rs/leptos/pull/1330<input name="host"> by @gbj in https://github.com/leptos-rs/leptos/pull/1332active_class prop on <A/> by @gbj in https://github.com/leptos-rs/leptos/pull/1323LEPTOS_OUTPUT_NAME correctly at compile time (closes #1337) by @gbj in https://github.com/leptos-rs/leptos/pull/1338<Suspense/> from resource reads when <Suspense/> is unmounted by @gbj in https://github.com/leptos-rs/leptos/pull/1342server_fn rustls feature shouldn't pull in default-tls by @gbj in https://github.com/leptos-rs/leptos/pull/1343ServerFnError when a server function is not found by @gbj in https://github.com/leptos-rs/leptos/pull/1350<ErrorBoundary/> children and fallback by @gbj in https://github.com/leptos-rs/leptos/pull/1354<ActionForm/> docs and add runtime warning for invalid encodings by @gbj in https://github.com/leptos-rs/leptos/pull/1360leptos_axum by @gbj in https://github.com/leptos-rs/leptos/pull/1374Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.4.0...v0.4.5
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Enough bugfixes and features have accumulated in the main branch that it's time for a new release. However, a very early change meant this needs to be
v0.4.0Enough bugfixes and features have accumulated in the main branch that it's time for a new release. However, a very early change meant this needs to be a semver bump. Rather than continuing the confusion of the feature/bug gap between 0.3.1 and main, this releases the current state of the main branch.
I was actually surprised, putting together these release notes, how much good stuff there is in here that I'd forgotten was new to this release!
This does not include the reactive ownership rewrite (#918), which I'd guess will be 0.5. But it does include the following...
leptos_axum now uses the (more common, more type-safe, more extensible) State and sub-state patterns rather than Extension to pass LeptosOptions. This will require a few small but key changes to apps uses Axum migrating from 0.3.x to 0.4.0. Click here to see a diff with the necessary changes.nightly and opting into stable, to requiring an opt-in for nightly features. Click here to see a diff with the necessary changes.
stable, remove the stable feature (it's now the default.)nightly, add the nightly feature to leptos, leptos_router, and leptos_metaleptos no longer defaults to csr, but is opt-in.
csr feature to leptos (same as leptos_router and leptos_metadefault-features = false on Leptos dependencies, as that mainly served to disable the default csr feature, which is no longer enabled by default.ServerFnError no longer implements std::error::Error (see below). ServerFnErrorErr does, if that's needed.<Suspense/> or <Transition/> are now rendered once, then subsequently cloned. If you are reading resources reactively (move || data.read(cx)) they should continue to update reactively. If you are reading resources non-reactively (<div>{resource.read(cx)}</div>) this would have worked previously, and now will not be reactive.Server functions no longer need to be registered (except on exotic platforms like server-side WASM). Instead, they are registered automatically, making it even easier to define and use them.
You can now use Axum extractors directly in server functions.
#[server(QueryExtract, "/api")]
pub async fn query_extract(cx: Scope) -> Result<String, ServerFnError> {
use axum::{extract::Query, http::Method};
use leptos_axum::extract;
extract(cx, |method: Method, res: Query<MyQuery>| async move {
format!("{method:?} and {}", res.q)
},
)
.await
.map_err(|_| ServerFnError::ServerError("Error with server extractor".into()))
}
Leptos now provides a leptos::error::Result type that behaves much like anyhow::Result (i.e., other errors can be converted into it using ?) but can be rendered directly in the view and caught by <ErrorBoundary/>. ServerFnError can also handle conversion from any error, making errors in server functions easier to handle.
use leptos::error::Result;
async fn fetch_cats(count: CatCount) -> Result<Vec<String>> {
if count > 0 {
// make the request
let res = reqwasm::http::Request::get(&format!(
"https://api.thecatapi.com/v1/images/search?limit={count}",
))
.send()
.await?
// convert it to JSON
.json::<Vec<Cat>>()
.await?
// extract the URL field for each cat
.into_iter()
.take(count)
.map(|cat| cat.url)
.collect::<Vec<_>>();
Ok(res)
} else {
Err(CatError::NonZeroCats.into())
}
}
#[server(AddTodo, "/api")]
pub async fn add_todo(title: String) -> Result<(), ServerFnError> {
let mut conn = db().await?;
Ok(
sqlx::query("INSERT INTO todos (title, completed) VALUES ($1, false)")
.bind(title)
.execute(&mut conn)
.await
.map(|_| ())?,
)
}
While routing, optionally wait for the next route to load before navigating, approximating the behavior of a multi-page app more closely, by using the set_is_pending prop on <Router/> and the <RoutingProgress/> component. (See #1055.)
#[component]
pub fn App(cx: Scope) -> impl IntoView {
let (is_routing, set_is_routing) = create_signal(cx, false);
view! { cx,
<Router set_is_routing> // will wait for async data on next page to load before navigating
https://github.com/leptos-rs/leptos/assets/286622/6ba39958-06c7-43b8-9a71-1a39132ffc07
<Await/>The new <Await/> component improves the ergonomics of loading async blocks.
async fn fetch_monkeys(monkey: i32) -> i32 {
// do some expensive work
3
}
view! { cx,
<Await
future=|cx| fetch_monkeys(3)
bind:data // see below for bind:
>
<p>{*data} " little monkeys, jumping on the bed."</p>
</Await>
}
bind: syntax on components and slotsThe children prop currently only supports one argument, the Scope. It's sometimes useful to be able to pass additional arguments to be used in children, but they need to be named. bind: allows you to define a children prop that takes additional arguments and name them. For example, the <Await/> component (see above) is defined like this
pub fn Await<T, Fut, FF, VF, V>(
/* ... other props */
children: VF,
) -> impl IntoView
where
/* ... other generics */
VF: Fn(Scope, &T) -> V + 'static,
The identifier for this second &T argument is then given with bind:{ident} (again, see above.)
<For/> implementation.#[server(MyServerFnType, "/api-prefix", "Url", "hello")] // will be at `/api-prefix/hello`
view macro.<Suspense/> hydration when no resources are read under it by @gbj in https://github.com/leptos-rs/leptos/pull/1046todomvc example style errors by @agilarity in https://github.com/leptos-rs/leptos/pull/1058todo_app_sqlite_axum by @gbj in https://github.com/leptos-rs/leptos/pull/1064style refers to class by @gbj in https://github.com/leptos-rs/leptos/pull/1066? prefix from search in browser (matching server behavior) - closes #1071 by @gbj in https://github.com/leptos-rs/leptos/pull/1077<For/> (closes #955, #1075, #1076) by @gbj in https://github.com/leptos-rs/leptos/pull/1078set() and update() by @gbj in https://github.com/leptos-rs/leptos/pull/1082? in navigation now that it is removed on browser side to match server by @gbj in https://github.com/leptos-rs/leptos/pull/1092<Await/> component to improve ergonomics of loading async blocks by @gbj in https://github.com/leptos-rs/leptos/pull/1091extract() function by @gbj in https://github.com/leptos-rs/leptos/pull/1093ssr_modes_axum by @gbj in https://github.com/leptos-rs/leptos/pull/1107form.rs:96 by @gbj in https://github.com/leptos-rs/leptos/pull/1142Scope by @gbj in https://github.com/leptos-rs/leptos/pull/1144<ActionForm/> by @gbj in https://github.com/leptos-rs/leptos/pull/1151<ActionForm/> by @gbj in https://github.com/leptos-rs/leptos/pull/1160bind: syntax for <Await/> component by @gbj in https://github.com/leptos-rs/leptos/pull/1158<ErrorBoundary/> IDs with new hydration key system by @gbj in https://github.com/leptos-rs/leptos/pull/1180FnOnce extractors by @gbj in https://github.com/leptos-rs/leptos/pull/1192set_pending now that <Transition/> body doesn't re-render by @gbj in https://github.com/leptos-rs/leptos/pull/1193<For /> apply_diff steps by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1196<use> in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/1203DynChild by @gbj in https://github.com/leptos-rs/leptos/pull/1211leptos-tailwind-axum to use main branch by @gbj in https://github.com/leptos-rs/leptos/pull/1218<ErrorBoundary/>/<Suspense/> relationship by @gbj in https://github.com/leptos-rs/leptos/pull/1210<For /> panic when clearing by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1220<ActionForm/> (closes #1205) by @gbj in https://github.com/leptos-rs/leptos/pull/1225<Transition/> transparent like <Suspense/> to avoid Scope issues (closes #1231) by @gbj in https://github.com/leptos-rs/leptos/pull/1232anyhow-like Result type for easier error handling by @gbj in https://github.com/leptos-rs/leptos/pull/1228nightly and csr features rather than stable and default-features = false by @gbj in https://github.com/leptos-rs/leptos/pull/1227leptos_meta and class attributes in SSR (closes #1238) by @gbj in https://github.com/leptos-rs/leptos/pull/1241Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.3.0...v0.4.0
However, there have been a number of breaking changes on main since 0.3.0 in preparation for 0.4.0, so main could not be released as 0.3.1. There are…
Earlier this week, the ouroboros crate, a dependency of leptos_reactive, identified a fundamental soundness issue. This was fixed immediately in Leptos on the main branch by switching to self_cell instead. However, there have been a number of breaking changes on main since 0.3.0 in preparation for 0.4.0, so main could not be released as 0.3.1. There are a number of other changes that need to be made before 0.4.0, so it did not make sense to immediately release a new major version.
This patch release just rewinds to 0.3.0 and replaces ouroboros, without including any additional features or changes since then. If you have already been using main, you should continue using main. If you have been using 0.3.0, you should update to 0.3.1.
See additional discussion here.
It includes several things that are breaking changes in the semantic-versioning sense, but you may find that not much breaks in your actual app. (For…
v0.3.0 is another incremental-ish release with a bunch of new features, many on the server end but including a bunch of general-purpose improvements. It includes several things that are breaking changes in the semantic-versioning sense, but you may find that not much breaks in your actual app. (For example, no code in any of the the three starter templates needed to change.)
__Props types for components; you can just use app::MyComponent; instead of app::{MyComponent, MyComponentProps};#[slot] syntax to define typed component children.window_event_listenerHtmlElement::optional_eventstyle: syntax in the view macro to set individual styles, much like class: sets individual classesResource::update method to reactively update current value.expect_context::<T>(cx) shorthand for use_context::<T>(cx).unwrap()GET requests (with either URL or CBOR encoding), for easier caching.extract helper to directly use Actix extractors in a server function.Vec<_> as server function arguments (anything that can be de/serialized by serde_qs)<Route/> in response to additional HTTP methods/verbs, e.g., the classic PHP/multi-page-app style in which a POST request can be sent to a page and it will render a response. (See methods prop.)SsrMode::PartiallyBlocked which works like out-of-order streaming but replaces the HTML for any “blocked” fragments on the server. Improves UX when JS is disabled.tracing crateleptos_meta with no features enabled or accidentally ending the view a component returns with a semicolon, meaning it renders nothing)<Suspense/>/<Transition/>.&'a str can no longer be directly rendered as a view: add .to_string() to effected variables. (Previously, all &str were converted to String by the renderer; using Cow<'static, str> now allows &'static str to be rendered without the additional allocation, at the cost of requiring the conversion of &str to String to be more explicit.)window_event_listener now takes a typed event (like ev::keypress). Use window_event_listener_untyped for the old behavior.Params to use typed router search/params, the FromStr error for any type needs to be Send + Sync so they are ErrorBoundary compatiblecreate_slice have changed to allow different input types for getter/setter; only relevant if (for some reason?) you were specifying them manually.Fix server functions default macro on stable by @Demonthos in https://github.com/leptos-rs/leptos/pull/784
docs: add runtime "strict mode" checks that warn if you’re non-reactively accessing a value by @gbj in https://github.com/leptos-rs/leptos/pull/786
fix: warnings about untracked signal access in <Router/> by @gbj in https://github.com/leptos-rs/leptos/pull/790
Remove unused fs dependency from leptos_config by @valeth in https://github.com/leptos-rs/leptos/pull/787
fix: untrack should disable warnings about untracked reads by @gbj in https://github.com/leptos-rs/leptos/pull/791
fix: nested <Suspense/> by @gbj in https://github.com/leptos-rs/leptos/pull/781
docs: <Form/> component by @gbj in https://github.com/leptos-rs/leptos/pull/792
Fix server functions with non-copy server contexts by @Demonthos in https://github.com/leptos-rs/leptos/pull/785
fix: unused warning on cx in server functions by @markcatley in https://github.com/leptos-rs/leptos/pull/794
docs: warn if you are using leptos_meta without features by @gbj in https://github.com/leptos-rs/leptos/pull/797
fix: warning in Cargo.toml by @markcatley in https://github.com/leptos-rs/leptos/pull/800
feat: Add ability to include options to event listeners by @Ofenhed in https://github.com/leptos-rs/leptos/pull/799
fix: fixes #802 as a temporary measure without resorting to #803 yet by @gbj in https://github.com/leptos-rs/leptos/pull/804
fix: prevent router panic on root-level <Redirect/> during route list generation by @gbj in https://github.com/leptos-rs/leptos/pull/801
Reduce size of RuntimeId when slotmap is not used by @novacrazy in https://github.com/leptos-rs/leptos/pull/805
fix: unused warning in reactive signal diagnostics by @markcatley in https://github.com/leptos-rs/leptos/pull/807
Add the ability for server fns to be submitted via GET requests by @benwis in https://github.com/leptos-rs/leptos/pull/789
chore: fix unused variable warning in property now that it's not memoized by @gbj in https://github.com/leptos-rs/leptos/pull/810
Optimize Runtime::mark_dirty by @novacrazy in https://github.com/leptos-rs/leptos/pull/808
Optimize memory usage of update methods by @novacrazy in https://github.com/leptos-rs/leptos/pull/809
fix: correctly escape HTML special characters in text nodes during SSR by @gbj in https://github.com/leptos-rs/leptos/pull/812
Publish book ci by @bram209 in https://github.com/leptos-rs/leptos/pull/817
remove Leptos guide link by @bram209 in https://github.com/leptos-rs/leptos/pull/818
docs: add sandbox links and max height by @gbj in https://github.com/leptos-rs/leptos/pull/824
fix: correctly pass server fn errors to client by @gbj in https://github.com/leptos-rs/leptos/pull/822
fix: server functions with url as argument name (closes issue #823) by @gbj in https://github.com/leptos-rs/leptos/pull/825
chore: deny warnings on github actions by @markcatley in https://github.com/leptos-rs/leptos/pull/814
Use local pools for axum handlers by @akarras in https://github.com/leptos-rs/leptos/pull/815
tests: update benchmarks by @gbj in https://github.com/leptos-rs/leptos/pull/827
feat: make __Props imports unnecessary (closes #746) by @gbj in https://github.com/leptos-rs/leptos/pull/828
Various optimizations, size reductions and stability improvements by @novacrazy in https://github.com/leptos-rs/leptos/pull/831
Fix leaked memo nodes by @novacrazy in https://github.com/leptos-rs/leptos/pull/841
[Fix] Correct broken MaybeSignal link by @hoangph271 in https://github.com/leptos-rs/leptos/pull/840
feat: rustls feature for reqwest and any other relevant dependencies by @gbj in https://github.com/leptos-rs/leptos/pull/842
fix: don't entity-encode HTML special characters inside <script> or <style> (closes #837) by @gbj in https://github.com/leptos-rs/leptos/pull/846
feat: allow multiple HTTP request methods/verbs by @gbj in https://github.com/leptos-rs/leptos/pull/695
[WIP] Trigger prototype by @novacrazy in https://github.com/leptos-rs/leptos/pull/838
fix static text nodes with curly braces in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/849
docs: emit error when trying to combine global class and dynamic class in a bugged way by @gbj in https://github.com/leptos-rs/leptos/pull/850
fix: custom events in SSR mode by @gbj in https://github.com/leptos-rs/leptos/pull/852
fix: Strip & from the end of params queries by @mondeja in https://github.com/leptos-rs/leptos/pull/854
fix: match statement in leptos book by @chroth7 in https://github.com/leptos-rs/leptos/pull/860
Fix the counter without macros test by @agilarity in https://github.com/leptos-rs/leptos/pull/863
feat: add ability to set node_ref and pass additional attributes to <Form/> and friends by @gbj in https://github.com/leptos-rs/leptos/pull/853
Fixed typo in life cycle docs by @Stackingttv in https://github.com/leptos-rs/leptos/pull/869
examples: fix error handling in fetch example by @gbj in https://github.com/leptos-rs/leptos/pull/870
feat: add the ability to specify animations on route transitions by @gbj in https://github.com/leptos-rs/leptos/pull/736
[fix] updated nix flakes lock files on session auth axum examples by @mustafasegf in https://github.com/leptos-rs/leptos/pull/872
docs: Add per-project toolchain override readme by @kamilogorek in https://github.com/leptos-rs/leptos/pull/876
feat: add non-animation base classes to <AnimatedOutlet/> and <AnimatedRoutes/> by @gbj in https://github.com/leptos-rs/leptos/pull/877
Use override key, if available, for server function calling by @snapbug in https://github.com/leptos-rs/leptos/pull/878
feat: add expect_context function by @markcatley in https://github.com/leptos-rs/leptos/pull/864
fix: <For/> rendering error in SSR InOrder/Async Mode by @hjin-me in https://github.com/leptos-rs/leptos/pull/879
Split counter without macros web test by @agilarity in https://github.com/leptos-rs/leptos/pull/884
fix: dispose of scope when server fns return error by @gbj in https://github.com/leptos-rs/leptos/pull/888
perf: tiny optimization on primitive child values by @gbj in https://github.com/leptos-rs/leptos/pull/887
chore(readme): add link to Matrix bridge by @filipdutescu in https://github.com/leptos-rs/leptos/pull/894
Fixes #890 that was using OnceLock, which is nightly only, by adding the once_cell crate as a dependency. by @OvermindDL1 in https://github.com/leptos-rs/leptos/pull/891
This should solve ParamsMap / LinearMap serde serialization and deserialization #892 by @dgsantana in https://github.com/leptos-rs/leptos/pull/895
feat: add ability to mutate resources by @gbj in https://github.com/leptos-rs/leptos/pull/886
fix: erroneous non-reactive access warning in undelegated events by @gbj in https://github.com/leptos-rs/leptos/pull/900
perf: improve router performance on server by calculating route branches once by @gbj in https://github.com/leptos-rs/leptos/pull/898
Added get_untracked for node_ref. by @dgsantana in https://github.com/leptos-rs/leptos/pull/902
Use cargo make to run tests for examples by @agilarity in https://github.com/leptos-rs/leptos/pull/904
Add a window event listener with a callback that receives an event that has been cast to its non-generic type. by @loganbnielsen in https://github.com/leptos-rs/leptos/pull/910
docs: compile error on mutually-exclusive features by @gbj in https://github.com/leptos-rs/leptos/pull/911
fix: issue with ordering of class attribute and class=("fancy-name-200", true) (closes #907) by @gbj in https://github.com/leptos-rs/leptos/pull/914
change: add window_event_listener_untyped and deprecate window_event_listener pending 0.3.0 by @gbj in https://github.com/leptos-rs/leptos/pull/913
feat: add slots by @yuuma03 in https://github.com/leptos-rs/leptos/pull/909
examples: fix broken counters tests by @gbj in https://github.com/leptos-rs/leptos/pull/915
fix some issues with animated routing by @gbj in https://github.com/leptos-rs/leptos/pull/889
fix: panic when creating nested StoredValue by @gbj in https://github.com/leptos-rs/leptos/pull/920
Tracing Updates by @benwis in https://github.com/leptos-rs/leptos/pull/908
docs: fixed a minor typo in async readme by @escwxyz in https://github.com/leptos-rs/leptos/pull/921
docs: removed extra unused code blocks in form.md by @escwxyz in https://github.com/leptos-rs/leptos/pull/923
docs: fixed typo in interlude_styling.md by @escwxyz in https://github.com/leptos-rs/leptos/pull/924
fix: features related compile error by @agilarity in https://github.com/leptos-rs/leptos/pull/919
fix: allow nested slots by @yuuma03 in https://github.com/leptos-rs/leptos/pull/928
docs: add some content on server-side rendering by @gbj in https://github.com/leptos-rs/leptos/pull/930
chore: specify dependency version for cached by @rodrigc in https://github.com/leptos-rs/leptos/pull/929
Remove need for LEPTOS_OUTPUT_NAME env var after compilation by @benwis in https://github.com/leptos-rs/leptos/pull/899
Added (potentially broken) timer example by @bluenote10 in https://github.com/leptos-rs/leptos/pull/925
Link to actual type instead of Into trait for component properties by @ModProg in https://github.com/leptos-rs/leptos/pull/932
feat: add allow missing_docs to children field by @ModProg in https://github.com/leptos-rs/leptos/pull/934
Adds the GetCbor and GetJson to server macro documentation. by @dgsantana in https://github.com/leptos-rs/leptos/pull/938
Fix ServerFnError::Serialization error string by @mtsr in https://github.com/leptos-rs/leptos/pull/939
examples: better practice for view types in todos by @gbj in https://github.com/leptos-rs/leptos/pull/940
CI: fix unused variables breaking tests by @gbj in https://github.com/leptos-rs/leptos/pull/950
fix: generics on impl From slot to Vec<slot> by @yuuma03 in https://github.com/leptos-rs/leptos/pull/946
feat: add Actix extract helper by @gbj in https://github.com/leptos-rs/leptos/pull/936
Test business logic for counter_without_macros by @agilarity in https://github.com/leptos-rs/leptos/pull/927
impl IntoView for component props by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/948
impl FromIterator for View by @ModProg in https://github.com/leptos-rs/leptos/pull/945
Add From for RequestParts into Parts for Axum and add an option to ge… by @benwis in https://github.com/leptos-rs/leptos/pull/931
fix: <ErrorBoundary/> toggling between states (closes issue #820) by @gbj in https://github.com/leptos-rs/leptos/pull/957
docs: add note on projecting children by @gbj in https://github.com/leptos-rs/leptos/pull/959
fix: escapes in doc comments on component properties by @ModProg in https://github.com/leptos-rs/leptos/pull/958
Add wasm web test and common tasks by @agilarity in https://github.com/leptos-rs/leptos/pull/954
docs: note need for serde dependency for server functions (closes #947) by @gbj in https://github.com/leptos-rs/leptos/pull/962
fix: use a HashMap on Branches::initialize by @yuuma03 in https://github.com/leptos-rs/leptos/pull/966
chore: fix typos by @fattenap in https://github.com/leptos-rs/leptos/pull/964
feat: add collect_view(cx) by @ModProg in https://github.com/leptos-rs/leptos/pull/956
v0.3.0-alpha by @gbj in https://github.com/leptos-rs/leptos/pull/968
Replace serde_urlencoded with serde_html_form to support cross-input vec serverfn by @snapbug in https://github.com/leptos-rs/leptos/pull/973
change/fix: require FromStr errors on Params to be Send + Sync so they are ErrorBoundary compatible by @gbj in https://github.com/leptos-rs/leptos/pull/974
Fix the lint issues in the counter example by @agilarity in https://github.com/leptos-rs/leptos/pull/971
feat: add builder syntax for optional event listener by @gbj in https://github.com/leptos-rs/leptos/pull/969
Fix lint issues in counter_isomorphic example by @agilarity in https://github.com/leptos-rs/leptos/pull/980
fix: suppress warning loading local resource without <Suspense/> in hydrate mode (closes #979) by @gbj in https://github.com/leptos-rs/leptos/pull/984
feat: allow structs in server function arguments by @gbj in https://github.com/leptos-rs/leptos/pull/987
docs: switch from compile errors to runtime warnings for incompatible feature flags by @gbj in https://github.com/leptos-rs/leptos/pull/990
docs: error when component ends with view! { ... }; (closes #985) by @gbj in https://github.com/leptos-rs/leptos/pull/993
fix: lint issues in counters example by @agilarity in https://github.com/leptos-rs/leptos/pull/986
fix: lint issues in erros_axum example by @agilarity in https://github.com/leptos-rs/leptos/pull/988
fix: lint issues in fetch example by @agilarity in https://github.com/leptos-rs/leptos/pull/989
fix: lint issues in hackernews example by @agilarity in https://github.com/leptos-rs/leptos/pull/991
fix: lint issues in hackernews_axum example by @agilarity in https://github.com/leptos-rs/leptos/pull/992
fix: lint issues in login_with_token_csr_only example by @agilarity in https://github.com/leptos-rs/leptos/pull/995
fix: lint issues in router example by @agilarity in https://github.com/leptos-rs/leptos/pull/996
fix: lint issues in session_auth_axum example by @agilarity in https://github.com/leptos-rs/leptos/pull/997
fix: lint issues in todo_app_sqlite example by @agilarity in https://github.com/leptos-rs/leptos/pull/998
fix: lint issues in todo_app_sqlite_axum example by @agilarity in https://github.com/leptos-rs/leptos/pull/999
fix: lint issues in todo_app_sqlite_viz example by @agilarity in https://github.com/leptos-rs/leptos/pull/1000
fix: lint issues in todomvc example by @agilarity in https://github.com/leptos-rs/leptos/pull/1001
[docs] Reduce firmness of overlapping signal warning by @dglsparsons in https://github.com/leptos-rs/leptos/pull/1004
docs: document that <ActionForm/> only works with form-encoded server functions by @gbj in https://github.com/leptos-rs/leptos/pull/1005
fix: properly dispose of <Suspense/> scopes (closes #834) by @gbj in https://github.com/leptos-rs/leptos/pull/1006
test: lint examples with --all-features by @agilarity in https://github.com/leptos-rs/leptos/pull/1008
feat: add style: to view by @gbj in https://github.com/leptos-rs/leptos/pull/1009
Relax Debug trait bounds by @Wadu436 in https://github.com/leptos-rs/leptos/pull/1010
docs: add a server fn section by @gbj in https://github.com/leptos-rs/leptos/pull/1014
book: close iframe tag on global state management page by @Wadu436 in https://github.com/leptos-rs/leptos/pull/1013
docs: adjust Dynamic Attributes page by @FrankReh in https://github.com/leptos-rs/leptos/pull/1011
book: fix link to cargo-leptos README by @Wadu436 in https://github.com/leptos-rs/leptos/pull/1012
docs: add examples for manual server integration by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1015
Clean up examples after verification by @agilarity in https://github.com/leptos-rs/leptos/pull/1019
build tailwind CSS with trunk by @agilarity in https://github.com/leptos-rs/leptos/pull/1016
[fix] indentation erros in examples by @hoangph271 in https://github.com/leptos-rs/leptos/pull/1017
fix: maintain insertion order of meta tags by @gbj in https://github.com/leptos-rs/leptos/pull/1021
fix: corrects error-deserialization behavior of ActionForm (closes #1024) by @gbj in https://github.com/leptos-rs/leptos/pull/1025
feat: SsrMode::PartiallyBlocked by @gbj in https://github.com/leptos-rs/leptos/pull/1026
fix: flicking <Transition/> in release mode (closes #960) by @gbj in https://github.com/leptos-rs/leptos/pull/1030
fix: avoid extra { escaping (closes #1035) by @gbj in https://github.com/leptos-rs/leptos/pull/1038
change: remove APIs that had been marked deprecated by @gbj in https://github.com/leptos-rs/leptos/pull/1037
Update slice.rs by @sjud in https://github.com/leptos-rs/leptos/pull/1036
examples: fix trunk config to run tailwind at the right time by @flosse in https://github.com/leptos-rs/leptos/pull/1040
Migrate axum integration to use with_state over layer(Extension by @snapbug in https://github.com/leptos-rs/leptos/pull/1032
Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.2.5...v0.3.0
Nothing published for this version
Nothing published for this version
This update includes many bug fixes and documentation improvements, along with a few new features:
v0.2.5This update includes many bug fixes and documentation improvements, along with a few new features:
<ProtectedRoute/> component that allows you to create route guards to either render or redirect away from a route depending on some condition.<Html/> and <Body/> components in leptos_meta.leptos_meta is now injected at the beginning of the <head> rather than the end, which allows you to inject an import map if necessary for JavaScript module imports.I'm beginning to merge a few server-rendering changes that should be invisible to most users but will technically be breaking API changes, and will be building toward v0.3.0 which will probably include reconfiguring the Cargo setup for nightly/stable support (see #591), so this is may be the last 0.2.x release.
wasm-bindgen dependency optional in leptos_reactive by @gbj in https://github.com/leptos-rs/leptos/pull/723console_log dependency to stable by @mondeja in https://github.com/leptos-rs/leptos/pull/724<Outlet/>s (closes issue #725) by @gbj in https://github.com/leptos-rs/leptos/pull/729<ActionForm> response redirects. by @andrew-chang-dewitt in https://github.com/leptos-rs/leptos/pull/728class attribute (closes #735) by @gbj in https://github.com/leptos-rs/leptos/pull/738<Suspense/> (closes issue #742) by @gbj in https://github.com/leptos-rs/leptos/pull/743Memo::get_untracked (closes issue #754) by @gbj in https://github.com/leptos-rs/leptos/pull/755counter_without_macros by @gbj in https://github.com/leptos-rs/leptos/pull/751is_mounted and dyn_classes by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/714use leptos::* in scope by @lpotthast in https://github.com/leptos-rs/leptos/pull/748</script> and other HTML tags in serialized resources by @gbj in https://github.com/leptos-rs/leptos/pull/763<Redirect/> between nested routes at same level by @gbj in https://github.com/leptos-rs/leptos/pull/767prop:value (closes #768) by @gbj in https://github.com/leptos-rs/leptos/pull/772<head> metadata tags at the beginning of the <head> by @gbj in https://github.com/leptos-rs/leptos/pull/731<Routes/> by @gbj in https://github.com/leptos-rs/leptos/pull/780Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.2.4...v0.2.5
feat: add set_interval_with_handle and deprecate set_interval by @gbj in https://github.com/leptos-rs/leptos/pull/709
v0.2.3 fixed support for stable Rust, which I temporarily broke in v0.2.2.
The main change in v0.2.4 is a rewritten reactive system. This didn't involve any breaking API changes, except to the extent that fixing bugs and glitchy behavior breaks apps that depend on the glitches. It pretty significantly improves the performance of the reactive system on deep graphs (i.e., when you have a chain of dependencies like memos leading from a signal to an effect), as well as fixing reactive "glitching" behaviors in ways that make effects run more efficiently. You can read more about the details here.
Other changes:
<ActionForm/>set_timeout, request_idle_callback, and request_animation_frame (all ending with with_handle)debounce helper that makes it easy to debounce event listenersSignalDispose trait (and .dispose()) function, to avoid leaking memory if you create a list of signals at the root scopeScope::batch() before running effects<ActionForm/> improvements by @gbj in https://github.com/leptos-rs/leptos/pull/676cargo machete systematically by @gbj in https://github.com/leptos-rs/leptos/pull/671cfg(not(debug_assertions))) by @Buzzec in https://github.com/leptos-rs/leptos/pull/679--release checks by @gbj in https://github.com/leptos-rs/leptos/pull/681leptos_meta by @gbj in https://github.com/leptos-rs/leptos/pull/684IntoView for ReadSignal and RwSignal in the stable feature. by @Buzzec in https://github.com/leptos-rs/leptos/pull/677<Suspense/> on same page during in-order or async rendering by @gbj in https://github.com/leptos-rs/leptos/pull/687<Suspense/> inside components in SSR mode by @gbj in https://github.com/leptos-rs/leptos/pull/688console_error_panic_hook::set_once() calls by @elliotwaite in https://github.com/leptos-rs/leptos/pull/692request_animation_frame and request_idle_callback by @elliotwaite in https://github.com/leptos-rs/leptos/pull/698debounce helper for event listeners by @gbj in https://github.com/leptos-rs/leptos/pull/691view! macro not compiling with a non-default scope name by @alexisfontaine in https://github.com/leptos-rs/leptos/pull/704set_interval_with_handle and deprecate set_interval by @gbj in https://github.com/leptos-rs/leptos/pull/709Scope::batch() by @gbj in https://github.com/leptos-rs/leptos/pull/711<Transition/> behavior by @gbj in https://github.com/leptos-rs/leptos/pull/717Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.2.2...v0.2.4
Nothing published for this version
bump bytecheck to 0.7, remove deprecated simdutf8_std. by @martinfrances107 in https://github.com/leptos-rs/leptos/pull/647
I forgot to make a tag or publish release notes for 0.2.1. These are both patch releases that include some performance improvements, a number of bugfixes, and spinning out a framework-independent server function crate, but don't include any particularly big new features.
Small new features
rkyv encoding as an option for resourcesclass = syntax in view! macroLeptosRequest<_> type that allows Leptos Axum apps access to the request via use_context, which allows you to use Axum extractors without a special handlercargo-leptos, for updating static parts of the view before recompiling the Rust parts of your app<For/> by @gbj in https://github.com/leptos-rs/leptos/pull/579rkyv encoding by @617a7a in https://github.com/leptos-rs/leptos/pull/577mouseenter and mouseleave do not bubble by @gbj in https://github.com/leptos-rs/leptos/pull/593Action::dispatch() set new value before resetting input signal by @Qwox0 in https://github.com/leptos-rs/leptos/pull/604render_to_stream by @gbj in https://github.com/leptos-rs/leptos/pull/601server_fn crate by @gbj in https://github.com/leptos-rs/leptos/pull/605view! macro class = (closes #612) by @gbj in https://github.com/leptos-rs/leptos/pull/614check instead of build in CI for disk space by @gbj in https://github.com/leptos-rs/leptos/pull/616generate_route_list (closes #582) by @gbj in https://github.com/leptos-rs/leptos/pull/621rkyv combos with other serialization traits by @gbj in https://github.com/leptos-rs/leptos/pull/622async actions and create_action by @gbj in https://github.com/leptos-rs/leptos/pull/623cargo-leptos by @gbj in https://github.com/leptos-rs/leptos/pull/592leptos-config and new functions for loading configuration by @vaniusrb in https://github.com/leptos-rs/leptos/pull/628create_effect chapter by @gbj in https://github.com/leptos-rs/leptos/pull/653IntoView for &Fragment by @gbj in https://github.com/leptos-rs/leptos/pull/655template macro by @gbj in https://github.com/leptos-rs/leptos/pull/661v0.2.2 by @gbj in https://github.com/leptos-rs/leptos/pull/667Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.2.0...v0.2.2
Nothing published for this version
v0.2.0 is an incremental change over 0.1.x. There are a few small things that have been breaking changes over the last two months, one big new feature…
v0.2.0v0.2.0 is an incremental change over 0.1.x. There are a few small things that have been breaking changes over the last two months, one big new feature, and a lot of small improvements and changes.
The biggest new feature of 0.2.0 that requires explanation is support for async rendering and in-order streaming, which you can activate via the new ssr prop on a <Route/>. (See the ssr_modes and ssr_modes_axum examples.)
With this new feature, Leptos now supports four different ways to render HTML that contains async data loaded under <Suspense/>. You can opt in to one or the other on a per-route basis.
fallback for any Suspense. Load data on the client, replacing fallback once they're loaded.
fallback for any Suspense. Load data on the server, streaming it down to the client as it resolves, and streaming down HTML for Suspense nodes.
async, with a very fast shell and resources that begin loading on the server.<head>)Suspense. At that point, wait for all its data to load, then render it, then the rest of the tree.
Suspense. Cannot begin hydration until the entire page has loaded, so earlier pieces
of the page will not be interactive until the suspended chunks have loaded.async: Load all resources on the server. Wait until all data are loaded, and render HTML in one sweep.
<head>). Faster complete load than synchronous because async resources begin loading on server.The mode defaults to out-of-order streaming. For a path that includes multiple nested routes, the most
restrictive mode will be used: i.e., if even a single nested route asks for async rendering, the whole initial
request will be rendered async. (async is the most restrictive requirement, followed by in-order, out-of-order, and synchronous.)
Because you have the ability to opt into these different modes on a per-route basis, you can choose the rendering strategy that is best for you—not only for your app in general, but for any given page.
<Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop<Redirect/> component in the router that works during client-side navigation or server-side renderingChildren, AttributeValue, and other type aliases to make it easier to accept a variety of types in your components0.1.3Resource::read() and Resource::with() now take a Scope as their first argument, i.e., resource.read() is now resource.read(cx). This is necessary for correct <Suspense/> behavior.Errors type has been modified to hide its internals and expose IntoIter directly. In 99% of cases this just means replacing references like errors.get().0.into_iter() with errors.get().into_iter()use leptos::* you probably won't notice the difference; if you are manually importing types you will need to import the signal traits as well.<For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }<ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoViewNodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.tomlChildren type alias by @gbj in https://github.com/leptos-rs/leptos/pull/403view macro fast-path SSR by @gbj in https://github.com/leptos-rs/leptos/pull/408<Html/> and <Body/> components in leptos_meta by @gbj in https://github.com/leptos-rs/leptos/pull/407<option> and <use> in SSR view macro by @gbj in https://github.com/leptos-rs/leptos/pull/416axum_errors example by @gbj in https://github.com/leptos-rs/leptos/pull/424RouteDefinition public by @gbj in https://github.com/leptos-rs/leptos/pull/430inner_html attribute by @gbj in https://github.com/leptos-rs/leptos/pull/429check instead of build (for CI) & add missing examples by @gbj in https://github.com/leptos-rs/leptos/pull/437<Show/> by @gbj in https://github.com/leptos-rs/leptos/pull/436<Outlet/> by @gbj in https://github.com/leptos-rs/leptos/pull/447on: event listeners on <Component/> nodes by @gbj in https://github.com/leptos-rs/leptos/pull/448leptos_router hydration issues by @gbj in https://github.com/leptos-rs/leptos/pull/450leptos_config description by @odiseo0 in https://github.com/leptos-rs/leptos/pull/455Children types to macro docs by @gbj in https://github.com/leptos-rs/leptos/pull/454fallback in <Show/> (closes #406) by @gbj in https://github.com/leptos-rs/leptos/pull/463<Redirect/> component (closes #412) by @gbj in https://github.com/leptos-rs/leptos/pull/466node_ref in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/471cargo doc in projects using #[server] by @gbj in https://github.com/leptos-rs/leptos/pull/476<ErrorBoundary/> by @gbj in https://github.com/leptos-rs/leptos/pull/478"openssl" feature from Actix examples by @gbj in https://github.com/leptos-rs/leptos/pull/480axum_errors example by @gbj in https://github.com/leptos-rs/leptos/pull/485inner_html in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/487#[derive(Params)] by @gbj in https://github.com/leptos-rs/leptos/pull/488debug_warn behavior in reactive crate and remove log dependency by @gbj in https://github.com/leptos-rs/leptos/pull/491Scope to view function in <For/> to avoid memory "leak" by @gbj in https://github.com/leptos-rs/leptos/pull/492index.html by @gbj in https://github.com/leptos-rs/leptos/pull/497rustfmt by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/483<For/> in todomvc example by @gbj in https://github.com/leptos-rs/leptos/pull/504leptos_dom and add Wasm build to CI for regressions by @gbj in https://github.com/leptos-rs/leptos/pull/510.unwrap() from redirect in Actix integration by @gbj in https://github.com/leptos-rs/leptos/pull/5140.2.0-alpha by @gbj in https://github.com/leptos-rs/leptos/pull/515Unit in empty views (closes #518) by @gbj in https://github.com/leptos-rs/leptos/pull/520web-sys event types to make it easier to type handlers by @gbj in https://github.com/leptos-rs/leptos/pull/521Errors and implement IntoIter by @gbj in https://github.com/leptos-rs/leptos/pull/522view macro with new exports by @gbj in https://github.com/leptos-rs/leptos/pull/525template macro by @gbj in https://github.com/leptos-rs/leptos/pull/526<Suspense/> (closes #527) by @gbj in https://github.com/leptos-rs/leptos/pull/531async rendering by @gbj in https://github.com/leptos-rs/leptos/pull/496v0.2.0-alpha2 by @gbj in https://github.com/leptos-rs/leptos/pull/539leptos_reactive in release mode by @gbj in https://github.com/leptos-rs/leptos/pull/540<Suspense/> by @gbj in https://github.com/leptos-rs/leptos/pull/545Scope into Resource::read() and Resource::with() by @gbj in https://github.com/leptos-rs/leptos/pull/542v0.2.0-beta by @gbj in https://github.com/leptos-rs/leptos/pull/557<ButtonC on:click/> syntax by @gbj in https://github.com/leptos-rs/leptos/pull/558create_resource, <Suspense/>, and <Transition/> by @gbj in https://github.com/leptos-rs/leptos/pull/559<Suspense/> fragments by @gbj in https://github.com/leptos-rs/leptos/pull/561transition fallback (closes #562) by @gbj in https://github.com/leptos-rs/leptos/pull/563<details> toggle event does not bubble (issue #565) by @gbj in https://github.com/leptos-rs/leptos/pull/566panic hygiene by @remkop22 in https://github.com/leptos-rs/leptos/pull/568<Transition/> with local_resource (closes #562) by @gbj in https://github.com/leptos-rs/leptos/pull/574Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.1.3...v0.2.0
NodeRef now takes NodeRef instead of NodeRef >. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as…
v0.2.0-betaThis release is a preview, and also serves to generate new docs on docs.rs, as the current ones are getting slightly out of sync with our main branch here.
0.2.0-alpha to 0.2.0-betaResource::read() and Resource::with() now take a Scope as their first argument, i.e., resource.read() is now resource.read(cx). This is necessary for correct <Suspense/> behavior.Errors type has been modified to hide its internals and expose IntoIter directly. In 99% of cases this just means replacing references like errors.get().0.into_iter() with errors.get().into_iter()use leptos::* you probably won't notice the difference; if you are manually importing types you will need to import the signal traits as well.Included below are the notes for 0.2.0-alpha, so you can see changes since 0.1.3 as well.
0.1.3<For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }<ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoViewNodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.toml<Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop<Redirect/> component in the router that works during client-side navigation or server-side renderingChildren, AttributeValue, and other type aliases to make it easier to accept a variety of types in your componentsUnit in empty views (closes #518) by @gbj in https://github.com/leptos-rs/leptos/pull/520web-sys event types to make it easier to type handlers by @gbj in https://github.com/leptos-rs/leptos/pull/521Errors and implement IntoIter by @gbj in https://github.com/leptos-rs/leptos/pull/522view macro with new exports by @gbj in https://github.com/leptos-rs/leptos/pull/525template macro by @gbj in https://github.com/leptos-rs/leptos/pull/526<Suspense/> (closes #527) by @gbj in https://github.com/leptos-rs/leptos/pull/531async rendering by @gbj in https://github.com/leptos-rs/leptos/pull/496v0.2.0-alpha2 by @gbj in https://github.com/leptos-rs/leptos/pull/539leptos_reactive in release mode by @gbj in https://github.com/leptos-rs/leptos/pull/540<Suspense/> by @gbj in https://github.com/leptos-rs/leptos/pull/545Scope into Resource::read() and Resource::with() by @gbj in https://github.com/leptos-rs/leptos/pull/542Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.2.0-alpha...v0.2.0-beta
Nothing published for this version
NodeRef now takes NodeRef instead of NodeRef >. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as…
v0.2.0-alphaThis release is a preview, and also serves to generate new docs on docs.rs, as the current ones are getting slightly out of sync with our main branch here.
I do not expect significant difficulties in migrating from 0.1.3 to 0.2.0. There are a few API tweaks here that necessitate a version bump but it's an order of magnitude smaller than the change from 0.0.x to 0.1.0 and will not touch most parts of your application.
<For/> component view argument now takes a Scope as its first argument, i.e., a change from view=move |counter| { ... } to view=move |cx, counter| { ... }<ErrorBoundary/> component fallback argument now takes a Fn(Scope, RwSignal<Errors>) -> impl IntoView instead of Fn(Scope, Option<RwSignal<Errors>>) -> impl IntoViewNodeRef now takes NodeRef<T> instead of NodeRef<HtmlElement<T>>. We're also deprecating NodeRef::new(cx) in favor of create_node_ref(cx) to follow the same pattern as everything else in the framework.cargo-leptos and the server integrations whether you're using cargo-leptos or not. The site_address field is now named site_addr; the compiler should actually prompt you correctly for this one.use leptos::* you may need to manually import a few additional types. We're also no longer reexporting wasm-bindgen, web-sys, and js-sys so you may need to add them as dependencies to your Cargo.toml<Html/> and <Body/> components in leptos_meta that let you change things like <html> lang and dir, and add a class to the <body>on: event listeners on <Component/> nodes, e.g., <MyFancyButton on:click=.../> without needing to create an on_click prop<Redirect/> component in the router that works during client-side navigation or server-side renderingChildren, AttributeValue, and other type aliases to make it easier to accept a variety of types in your componentsChildren type alias by @gbj in https://github.com/leptos-rs/leptos/pull/403view macro fast-path SSR by @gbj in https://github.com/leptos-rs/leptos/pull/408<Html/> and <Body/> components in leptos_meta by @gbj in https://github.com/leptos-rs/leptos/pull/407<option> and <use> in SSR view macro by @gbj in https://github.com/leptos-rs/leptos/pull/416axum_errors example by @gbj in https://github.com/leptos-rs/leptos/pull/424RouteDefinition public by @gbj in https://github.com/leptos-rs/leptos/pull/430inner_html attribute by @gbj in https://github.com/leptos-rs/leptos/pull/429check instead of build (for CI) & add missing examples by @gbj in https://github.com/leptos-rs/leptos/pull/437<Show/> by @gbj in https://github.com/leptos-rs/leptos/pull/436<Outlet/> by @gbj in https://github.com/leptos-rs/leptos/pull/447on: event listeners on <Component/> nodes by @gbj in https://github.com/leptos-rs/leptos/pull/448leptos_router hydration issues by @gbj in https://github.com/leptos-rs/leptos/pull/450leptos_config description by @odiseo0 in https://github.com/leptos-rs/leptos/pull/455Children types to macro docs by @gbj in https://github.com/leptos-rs/leptos/pull/454fallback in <Show/> (closes #406) by @gbj in https://github.com/leptos-rs/leptos/pull/463<Redirect/> component (closes #412) by @gbj in https://github.com/leptos-rs/leptos/pull/466node_ref in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/471cargo doc in projects using #[server] by @gbj in https://github.com/leptos-rs/leptos/pull/476<ErrorBoundary/> by @gbj in https://github.com/leptos-rs/leptos/pull/478"openssl" feature from Actix examples by @gbj in https://github.com/leptos-rs/leptos/pull/480axum_errors example by @gbj in https://github.com/leptos-rs/leptos/pull/485inner_html in SSR by @gbj in https://github.com/leptos-rs/leptos/pull/487#[derive(Params)] by @gbj in https://github.com/leptos-rs/leptos/pull/488debug_warn behavior in reactive crate and remove log dependency by @gbj in https://github.com/leptos-rs/leptos/pull/491Scope to view function in <For/> to avoid memory "leak" by @gbj in https://github.com/leptos-rs/leptos/pull/492index.html by @gbj in https://github.com/leptos-rs/leptos/pull/497rustfmt by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/483<For/> in todomvc example by @gbj in https://github.com/leptos-rs/leptos/pull/504leptos_dom and add Wasm build to CI for regressions by @gbj in https://github.com/leptos-rs/leptos/pull/510.unwrap() from redirect in Actix integration by @gbj in https://github.com/leptos-rs/leptos/pull/5140.2.0-alpha by @gbj in https://github.com/leptos-rs/leptos/pull/515Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.1.3...v0.2.0
The big changes here are the ` ` and ` ` components. Many thanks to @benwis for leading the work on these.
The big changes here are the <ErrorBoundary/> and <Show/> components. Many thanks to @benwis for leading the work on these.
You should also see a very significant improvement in SSR performance, as well as small reductions in Wasm binary sizes, and some overall bugfixes and improvements.
Oh, and... 🎵🎶 We don't talk about 0.1.2. 🎶🎵
view! macro by @gbj in https://github.com/leptos-rs/leptos/pull/344<script>, <style>, and <title> to set of ambiguous elements by @gbj in https://github.com/leptos-rs/leptos/pull/350class = ..., in view macro to support scoped styling by @gbj in https://github.com/leptos-rs/leptos/pull/351#[component] docs and please clippy by @gbj in https://github.com/leptos-rs/leptos/pull/362hgroup element by @ModProg in https://github.com/leptos-rs/leptos/pull/379From<Signal<T>> for MaybeSignal<T> by @gbj in https://github.com/leptos-rs/leptos/pull/384cx in server fn arguments by @gbj in https://github.com/leptos-rs/leptos/pull/385<ActionForm/> behavior with Action by @gbj in https://github.com/leptos-rs/leptos/pull/390gloo dependency in leptos_dom by @gbj in https://github.com/leptos-rs/leptos/pull/391v0.1.2 by @gbj in https://github.com/leptos-rs/leptos/pull/397Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.1.1...v0.1.3
Nothing published for this version
0.1.1 is mostly a series of bugfixes to `0.1.0`; see the 0.1.0 release notes for a list of new features in this series. Thanks to our new contributors
0.1.1 is mostly a series of bugfixes to 0.1.0; see the 0.1.0 release notes for a list of new features in this series. Thanks to our new contributors, and to everyone who's helped find bugs.
create_slice and edit doc comment slightly by @gbj in https://github.com/leptos-rs/leptos/pull/314<Router fallback> (signature and functionality) by @gbj in https://github.com/leptos-rs/leptos/pull/324Debug on MetaContext by @gbj in https://github.com/leptos-rs/leptos/pull/329MetaContext debug for wasm target by @gbj in https://github.com/leptos-rs/leptos/pull/334RouteContext in nested routes with different parameters by @gbj in https://github.com/leptos-rs/leptos/pull/345<Suspense/> to a specialized type that uses comments for SSR by @gbj in https://github.com/leptos-rs/leptos/pull/346Full Changelog: https://github.com/leptos-rs/leptos/compare/v0.1.0...v0.1.1
Finally, here's the release for version 0.1.0. Thanks to everyone who's been working with the alpha, beta, and bleeding-edge versions over the last fe
Finally, here's the release for version 0.1.0. Thanks to everyone who's been working with the alpha, beta, and bleeding-edge versions over the last few weeks to help get everything ready.
Most of the release notes below are copied from the 0.1.0-alpha release, but include a few updates. All these changes are relative to 0.0.22.
You can now easily mix and match different types of node in a Fragment, which previously needed to be a Vec of all the same types (like a Vec<Fragment>).
view! { cx,
<>
"This is some text."
<p>"Here's an element."</p>
<ComponentA/>
</>
}
In fact, the <> fragment itself is optional.
view! { cx,
"This is some text."
<p>"Here's an element."</p>
<ComponentA/>
}
HTML elements generated by the view! macro are now typed, and implement Deref to give a correctly-typed web_sys element.
// returns `HtmlElement<Input>`
// derefs to a `web_sys::HtmlInputElement`
view! { cx, <input type="text"/> }
store_valueYou can now store non-reactive values in the reactive system to take advantage of the same Copy + 'static reference system without the overhead or abstraction leak of storing something in a signal. This is useful for objects you need to reference in multiple places throughout your application without cloning.
// this structure is neither `Copy` nor `Clone`
pub struct MyUncloneableData {
pub value: String
}
// ✅ you can move the `StoredValue` into closures and access it with .with()
let data = store_value(cx, MyUncloneableData { value: "a".into() });
let callback_a = move || data.with(|data| data.value == "a");
let callback_b = move || data.with(|data| data.value == "b");
Signal<T> and SignalSetter<T> abstractionsThese wrappers allow you to define APIs that can take any kind of signal. For example, Signal<T> can be a ReadSignal, RwSignal, Memo, or derived signal. This is especially useful when defining components interfaces. (There's even a MaybeSignal for types that may just be T or may be a Signal<T>.)
let (count, set_count) = create_signal(cx, 2);
let double_count = Signal::derive(cx, move || count() * 2);
let memoized_double_count = create_memo(cx, move |_| count() * 2);
// this function takes any kind of wrapped signal
fn above_3(arg: &Signal<i32>) -> bool {
// ✅ calling the signal clones and returns the value
// it is a shorthand for arg.get()
arg() > 3
}
assert_eq!(above_3(&count.into()), false);
assert_eq!(above_3(&double_count), true);
assert_eq!(above_3(&memoized_double_count.into()), true);
DX with this new system is much better. You'll see hugely improved language-server integration for the view! macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.
#[component] macroYou can now document components and their properties directly in the #[component] macro like this:
/// A simple counter component.
///
/// You can use doc comments like this to document your component.
#[component]
pub fn SimpleCounter(
cx: Scope,
/// The starting value for the counter
#[prop(optional)]
initial_value: i32,
/// The change that should be applied each time the button is clicked.
step: i32
) -> impl IntoView {
// ...
}
The macro will automatically generate docs for the components and for each of its props.
#[prop] attributes for component propsYou can use the #[prop] attribute macro to mark component props in several ways:
#[prop(into)]: This will call .into() on any value passed into the component prop. (For example,
you could apply #[prop(into)] to a prop that takes Signal, which would
allow users to pass a ReadSignal or RwSignal
and automatically convert it.)#[prop(optional)]: If the user does not specify this property when they use the component,
it will be set to its default value. If the property type is Option<T>, values should be passed
as name=T and will be received as Some(T).#[prop(optional_no_strip)]: The same as optional, but requires values to be passed as None or
Some(T) explicitly. This means that the optional property can be omitted (and be None), or explicitly
specified as either None or Some(T).#[prop(default = X)]: The property is optional, and will be set to the default value provided if it is not passed.tracing supportWe've added support for debugging using the tracing crate, integrated into both the renderer and the reactive system. This means that when an effect or an event listener fires, you can use trace!(...) to get an insight into the flow of your program. See leptos_dom/examples/test-bench for an example setup; a separate crate to make this tracing setup easier will be forthcoming.
cargo-leptos integration improvementscargo-leptos 0.1.2 and the Actix/Axum integrations in 0.1.0 now work together seamlessly, allowing you to create full-stack applications with as little boilerplate as possible.
<Router/> in a <div> for no obvious reasonview macroHere are a few things to watch out for as you migrate:
cargo-leptos already and run into any issues (for example, with the path of a JS or Wasm file), be sure to check out the latest examples and the starter. The extra structures here have changed a bit over time as we've tried to figure out the best patterns. Cloning the starter and adding your existing application code should work fine.-> impl IntoView<For/> component now takes a view property, instead of you passing the view function as the child of the component<Route/> component takes a view property instead of element for consistencychildren properties are now typed Box<dyn Fn(Scope) -> Fragment>view! macro returns distinct structures, which are all different types. In other words, this code no longer compiles// this won't work
if some_condition {
view! { cx, <p>"P if true"</p> }
} else {
view! { cx, <span>"SPAN if false"</span> }
}
because the first branch now returns HtmlElement<P> while the second returns HtmlElement<Span>.
In this case, simply add .into_any() to each to return HtmlElement<AnyElement> from both. In general, you can always call .into_view(cx) to return a wrapping View type instead.
// this works
if some_condition {
view! { cx, <p>"P if true"</p> }.into_any()
} else if something_else {
view! { cx, <span>"SPAN if false"</span> }.into_any()
}
This release mostly (see crates.io) consists mainly of polishing the many changes described in the `0.1.0-alpha` release notes.
v0.1.0-betaThis release mostly (see crates.io) consists mainly of polishing the many changes described in the 0.1.0-alpha release notes.
Other significant improvements include:
store_value() and StoredValue APIs that allow you to use the reactive system to store Copy and 'static handles to non-reactive values, just as you can with reactive signals.cargo-leptos build tool, including transitioning most of the examples over to use cargo-leptos (except for the client-only examples, which use Trunk) (kudos and many thanks to @benwis and @akesson)stable support for the new version (thanks to @jquesada2016)... in addition to many small bug-fixes.
We're making very good progress toward a final 0.1.0 release. The only outstanding changes at this point involve improving and updating documentation, slightly loosening a couple APIs to make them easier to use (for example, allowing the path property on <Route/> to take T: impl std::fmt::Display rather than &'static str), and a few performance improvements (like optimized SSR) that will have absolutely no effect on the API exposed to users, but continue to ensure high performance and a good experience.
I thought I'd offer this alpha release of the upcoming 0.1.0 so you can get a taste for some of what we've been working on. Shout out to @jquesada2016
v0.1.0🎄 Merry Christmas!
I thought I'd offer this alpha release of the upcoming 0.1.0 so you can get a taste for some of what we've been working on. Shout out to @jquesada2016 for driving the work on the rewritten renderer that got us here, as well as huge improvements to the #[component] macro and many other details of the framework.
You can track the current state of this work in PR #119. You can download the alpha from crates.io.
There are a few known issues still (see below) but this release should be more or less usable, and the APIs are pretty much final. You can expect something closer to a final release in the next few weeks, but here's what to look forward to in the meantime.
You can now easily mix and match different types of node in a Fragment, which previously needed to be a Vec of all the same types (like a Vec<Fragment>).
view! { cx,
<>
"This is some text."
<p>"Here's an element."</p>
<ComponentA/>
</>
}
HTML elements generated by the view! macro are now typed, and implement Deref to give a correctly-typed web_sys element.
// returns `HtmlElement<Input>`
// derefs to a `web_sys::HtmlInputElement`
view! { cx, <input type="text"/> }
DX with this new system is much better. You'll see hugely improved language-server integration for the view! macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.
#[component] macroYou can now document components and their properties directly in the #[component] macro like this:
/// A simple counter component.
///
/// You can use doc comments like this to document your component.
#[component]
pub fn SimpleCounter(
cx: Scope,
/// The starting value for the counter
#[prop(optional)]
initial_value: i32,
/// The change that should be applied each time the button is clicked.
step: i32
) -> impl IntoView {
// ...
}
The macro will automatically generate docs for the components and for each of its props.
#[prop] attributes for component propsYou can use the #[prop] attribute macro to mark component props in several ways:
#[prop(optional)]: this property is not required, and will default to Default::default() if you don't provide it in the view#[prop(into)]: .into() will be called to convert the arguments provided in the view you can specify, to save you adding .into() in your views<Router/> in a <div> for no obvious reasonHere are a few things to watch out for as you migrate:
-> impl IntoView<For/> component now takes a view property, instead of you passing the view function as the child of the component<Route/> component takes a view property instead of element for consistencychildren properties are now typed Box<dyn Fn(Scope) -> Fragment>view! macro returns distinct structures, which are all different types. In other words, this code no longer compiles// this won't work
if some_condition {
view! { cx, <p>"P if true"</p> }
} else {
view! { cx, <span>"SPAN if false"</span> }
}
because the first branch now returns HtmlElement<P> while the second returns HtmlElement<Span>.
In this case, simply add .into_any() to each to return HtmlElement<AnyElement> from both. In general, you can always call .into_view(cx) to return a wrapping View type instead.
// this works
if some_condition {
view! { cx, <p>"P if true"</p> }.into_any()
} else if something_else {
view! { cx, <span>"SPAN if false"</span> }.into_any()
}
<Transition/> component doesn't quite work properly yet.create_resource and read it without using <Suspense/>view! macro yetstable support for leptos_router and leptos_metaNothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.