Releases: leptos-rs/leptos
v0.5.0-beta
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 General
Reactive System Changes
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- You may have some
|_, _|
that become|_|
or|_|
that become||
, particularly for thefallback
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
.
Other New Features
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.
Other Changes
use_navigate
navigate function no longer returns a value
The 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 removal
This 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());
}
Expected to Not Work
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.
v0.4.8
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
.
New Features
mut
in component props
This 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
type
MaybeProp
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
- may or may not be provided
- if provided, may be a plain value or a signal
- if a signal type, may or may not have a value (i.e., are a
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>
}
}
v0.4.7
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
.
New Features
mut
in component props
This 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
type
MaybeProp
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
- may or may not be provided
- if provided, may be a plain value or a signal
- if a signal type, may or may not have a value (i.e., are a
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>
}
}
What's Changed
- (doc)expand spawn_local documentation by @Bechma in #1433
- fix(examples): unable to parse makefile (#1440) by @agilarity in #1441
- fix: incorrect opening node for
<Each/>
in debug mode (closes #1168) by @gbj in #1436 - docs: fix typo in 23_ssr_modes.md by @gbj in #1445
- feat: add
MaybeProp
type by @gbj in #1443 - perf(examples): speed up the test-info report (#1446) by @agilarity in #1447
- feat: allow
mut
in component props and suppress "needless lifetime" warning (closes #1458) by @gbj in #1459 - fix:
AnimatedShow
- possible panic on cleanup by @sebadob in #1464 - Document the magic number 128 as FILTER_SHOW_COMMENT. by @martinfrances107 in #1468
- Update README.md by @randommm in #1470
- fix: properly replace text nodes in DynChild (closes #1456) by @gbj in #1472
- fix: compile-time regression for deeply-nested component trees by @gbj in #1476
- fix: correctly escape HTML in DynChild text nodes by @gbj in #1478
- Minor: doclink to Error needed FQDN. by @martinfrances107 in #1469
- Fix typo in docs for
ServerFnErrorErr
by @DanikVitek in #1477 - fix: correctly export all DOM helpers by @gbj in #1486
New Contributors
- @Bechma made their first contribution in #1433
- @randommm made their first contribution in #1470
- @DanikVitek made their first contribution in #1477
Full Changelog: v0.4.6...v.0.4.7
v0.5.0-alpha
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- You may have some
|_, _|
that become|_|
or|_|
that become||
, particularly for thefallback
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
.
Expected to Not Work
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.
Help Wanted
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.
v0.4.6
Features
- Improved support for a wider set of valid HTML attribute names (like
class:something-500
) not previously supported (@vldm in #1416) - Get and set individual URL search/query params with
create_query_signal
(@tqwewe in #1377) - feat: create an
<AnimatedShow>
component (closes #1370) (@sebadob in #1386) - feat: implement
Resource::dispose()
by @gbj in #1393
Miscellaneous
- Doc proof-reading by @aperepel in #1380
- refactor: remove unnecessary string allocation in
TryFrom
forUrl
by @tqwewe in #1376 - docs: small issues by @gbj in #1385
- docs: correct docs for
create_memo
to reflect laziness by @gbj in #1388 - Minor: Removed call to .into(), plus minor touch to docs. by @martinfrances107 in #1396
- examples: remove random
<form>
by @gbj in #1398 - Proofreading 15_global_state.md by @aperepel in #1395
- Proofreading README.md by @aperepel in #1399
- ci: lint with clippy by @agilarity in #1379
- Proofreading 16_routes.md by @aperepel in #1405
- docs/examples: use shorthand form for
<Route/>
views when possible by @gbj in #1375 - fix:
RawText
/unquoted text nodes in SSR (closes #1384) by @gbj in #1407 - fix: closing element names wrong for
svg::
,math::
, anduse_
(closes #1403) by @gbj in #1406 - fix:
<use_/>
as typed top-level element in view by @gbj in #1410 - build(examples): make it easy to see which examples do what kind of testing by @agilarity in #1411
- docs: note about typed params on stable by @gbj in #1414
- Typo fix by @DougAnderson444 in #1412
- fix typo for WrapsChildren by @icub3d in #1402
- docs: CONTRIBUTING.md with helpful info re: CI by @gbj in #1415
- chore: resolve clippy
incorrect_clone_impl_on_copy_type
(closes #1401) by @gbj in #1418 - Fix warning message about updating a signal after it has been disposed by @jasonrhansen in #1423
- Docs proofreading and fixing the links by @aperepel in #1425
- fix: clear
<title>
correctly when navigating between pages by @gbj in #1428 - build(examples): pull up compile tasks by @agilarity in #1417
- build(examples): update Makefiles for recent examples by @gbj in #1431
- Binary search dom stuff by @g-re-g in #1430
New Contributors
- @aperepel made their first contribution in #1380
- @DougAnderson444 made their first contribution in #1412
- @icub3d made their first contribution in #1402
- @sebadob made their first contribution in #1386
- @mforsb made their first contribution in #1432
Full Changelog: v0.4.5...v0.4.6
v0.4.5
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.
- Some useful fixes to support for
cargo leptos watch --hot-reload
leptos_axum::extract_with_state
to support extractors that use aState
, if it's been provided via context in a custom handler- The
watch
function, which functions as a more configurablecreate_effect
, including the ability to explicitly list dependencies, stop listening to them, whether to run immediately or lazily, etc. - Better 404 page support in Actix examples and templates
- Added support for adding Content-Security-Policy nonces to inline script and style tags with
use_nonce
and thenonce
feature - Rewritten
<For/>
diffing algorithm that both fixes a number of correctness issues/edge cases in<For/>
and drops ~10kb from the WASM binary
Basically, 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.
Complete Changelog
v0.4.0
by @gbj in #1250- chore: remove unused variable warnings with ssr props by @tqwewe in #1244
- test(counters_stable): add missing e2e tests by @agilarity in #1251
- docs: update server fn docs by @gbj in #1252
- test(router_example): add playwright tests by @nomorechokedboy in #1247
- Add fallback support for workspace in get_config_from_str by @afiqzx in #1249
- fix: regression in ability to use signals directly in the view in stable by @gbj in #1254
- fix: hot-reloading view marker line number by @gbj in #1255
- docs: update 02_getting_started.md by @gbj in #1256
- example/readme: Link to 'VS Browser' ext; format. by @srid in #1261
- chore: new
cargo fmt
by @gbj in #1266 - feat: implement PartialEq on ServerFnError by @M1cha in #1260
- Minor: Ran cargo clippy --fix and reviewed changes. by @martinfrances107 in #1259
- fix:
HtmlElement::dyn_classes()
when adding classes by @gbj in #1265 - fix: clearing
<For/>
that has a previous sibling in release mode (fixes #1258) by @gbj in #1267 - Added watch by @maccesch in #1262
- fix: error messages in
dyn_classes
by @gbj in #1270 - docs: add docs on responses/redirects and clarification re: Axum
State(_)
extractors by @gbj in #1272 - fix: improved diagnostics about non-reactive signal access by @gbj in #1277
- fix: duplicate text nodes during
<For/>
hydration (closes #1279) by @gbj in #1281 - fix: untracked read in
<Redirect/>
by @gbj in #1280 - fix: issue with class hydration not removing classes correctly by @gbj in #1287
- fix: use
once_cell::OnceCell
rather thanstd::OnceCell
by @gbj in #1288 - leptos axum extract with state by @sjud in #1275
- examples: add 404 support in Actix examples (closes #1031) by @gbj in #1291
- fixed example for error handling by @webmstk in #1292
- Adding instructions to add a tailwind plugin to examples. by @dessalines in #1293
- chore: add
mdbook
in flake by @gbj in #1299 - test(counters_stable): add wasm testing by @agilarity in #1278
- fixed typo in parent-child doc by @webmstk in #1300
- Rework diff functionality for Each component by @g-re-g in #1296
- docs: must use
View
by @gbj in #1302 - docs: fix braces in
<Show/>
example by @gbj in #1303 - fix:
<ActionForm/>
should check origin correctly before doing a full-page refresh by @gbj in #1304 - feat: use lazy thread local for regex by @tqwewe in #1309
- test(counters_stable/wasm): enter count by @agilarity in #1307
- docs: clarify WASM target by @gbj in #1318
- update warnings to remove mention of csr as a default feature by @Heliozoa in #1313
- docs: typo by @maheshbansod in #1315
- docs: typo & punctuation by @maheshbansod in #1316
- refactor(ci): improve the organization of
cargo make
tasks by @agilarity in #1320 - feat(leptos-config): kebab-case via serde's rename_all by @filipdutescu in #1308
- fix:
<ActionForm/>
should set value even if redirected by @gbj in #1321 - feat(config): implement common traits for Env by @filipdutescu in #1324
- fix: Actix server fn
redirect()
duplicateLocation
headers by @gbj in #1326 - Bump indexmap to version 2 by @g-re-g in #1325
- fix: warning generated by new
#[must_use]
on views by @gbj in #1329 - docs: clarify
nightly
in "Getting Started" by @gbj in #1330 - fix: event delegation issue with
<input name="host">
by @gbj in #1332 - feat: allow
active_class
prop on<A/>
by @gbj in #1323 - fix: routing logic to scroll to top was broken by @gbj in #1335
- fix: check
LEPTOS_OUTPUT_NAME
correctly at compile time (closes #1337) by @gbj in #1338 - fix: un-register
<Suspense/>
from resource reads when<Suspense/>
is unmounted by @gbj in #1342 - build: run tasks from workpace or member directory by @agilarity in #1339
- docs: how not to mutate the DOM during rendering by @gbj in #1344
- fix:
server_fn
rustls
feature shouldn't pull indefault-tls
by @gbj in #1343 - Book, don't run rust code snippets and update getting started by @g-re-g in #1346
- use cfg_attr for conditional derives by @circuitsacul in #1349
- docs: improve
ServerFnError
when a server function is not found by @gbj in #1350 - docs: don't warn when a resource resolves after its scope has been disposed by @gbj in #1351
- fix: duplicated meta content during async rendering by @gbj in #1352
- ci: speed up verification by @agilarity in #1347
- fix: hydration-key conflicts between
<ErrorBoundary/>
children and fallback by @gbj in #1354 - feat: add support for adding CSP nonces by @gbj in #1348
- docs/warning: fix
<ActionForm/>
docs and add runtime warning for invalid encodings by @gbj in #1360 - ci(ci): only run on source change by @agilarity in #1357
- ci(check-examples): only run on source change by @agilarity in #1356
- fix: correctly show fallback for Transition on first load even if not hydrating by @gbj in #1362
- fix: update link to example code in book testing page by @BakerNet in #1365
- doc: previews to backup CodeSandbox by @jdevries3133 in #1169
- Hot reload bug-fix by @sebastian in #1368
- perf: exclude hydration code in CSR mode by @gbj in #1372
- fix: release lock on stored values...
`v0.4.0`
v0.4.0
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 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...
Breaking Changes
leptos_axum
now uses the (more common, more type-safe, more extensible)State
and sub-state patterns rather thanExtension
to passLeptosOptions
. 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.- Switch from defaulting to
nightly
and opting intostable
, to requiring an opt-in fornightly
features. Click here to see a diff with the necessary changes.- If you're using
stable
, remove thestable
feature (it's now the default.) - If you're using
nightly
, add thenightly
feature toleptos
,leptos_router
, andleptos_meta
- If you're using
leptos
no longer defaults tocsr
, but is opt-in.- If you're using CSR, add the
csr
feature toleptos
(same asleptos_router
andleptos_meta
- If you're using SSR/hydration, you can remove most
default-features = false
on Leptos dependencies, as that mainly served to disable the defaultcsr
feature, which is no longer enabled by default.
- If you're using CSR, add the
ServerFnError
no longer implementsstd::error::Error
(see below).ServerFnErrorErr
does, if that's needed.- The children of a
<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.
Features
Automatic Server Function Registration
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.
Axum Extractor Support
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()))
}
Improved Error Handling
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(|_| ())?,
)
}
Async Routing
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
Screen.Recording.2023-05-20.at.9.34.42.PM.mov
<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 slots
The 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.)
Other Features
- Rewritten and less-buggy
<For/>
implementation. - Specify exact server function paths with a fourth argument, rather than the hashed path used by default to avoid name collisions
#[server(MyServerFnType, "/api-prefix", "Url", "hello")] // will be at `/api-prefix/hello`
- Significant reductions in overhead of hydration keys, and therefore in SSR performance.
- Improvements to recoverability, error handling, and syntax highlighting in the
view
macro.
Full Changelog
- fix: typo in actix extract documentation by @markcatley in #1043
- fix:
<Suspense/>
hydration when no resources are read under it by @gbj in #1046 - docs: fix small docs issues (closes #1045) by @gbj in #1049
- docs: fix typo in view fn by @kasbuunk in #1050
- Update lib.rs by @sjud in #1053
- fix: multipart forms on server fns by @yuuma03 in #1048
- tests: fix broken SSR doctests by @gbj in #1056
- fix:
todomvc
example style errors by @agilarity in #1058 - Added Debug, PartialEq and Eq derives to trigger. by @dgsantana in #1060
- examples: fix
todo_app_sqlite_axum
by @gbj in #1064 - test: verify tailwind example with playwright tests by @agilarity in #1062
- fix: docs note on
style
refers toclass
by @gbj in #1066 - docs: update notes on WASM binary size to work with SSR too (closes #1059) by @gbj in #1068
- docs: clarify SSR/WASM binary size comments by @gbj in #1070
- Specify Server Fn Paths by @benwis in #1069
- test: setup e2e automatically for tailwind example by @agilarity in #1067
- Rsx parser with recovery after errors, and unquoted text by @vldm in #1054
- feat: add "async routing" feature by @gbj in #1055
- fix/change: remove
?
prefix fromsearch
in browser (matching server behavior) - closes #1071 by @gbj in #1077 - fix: debug-mode bugs in
<For/>
(closes #955, #1075, #1076) by @gbj in #1078 - docs: clarify difference between
set()
andupdate()
by @gbj in #1082 - feat: manually implement Debug, PartialEq, Eq and Hash for reactive types by @Skyliegirl33 in #1080
- fix: correctly handle new navigations while in the middle of an async navigation by @gbj in #1084
- Docs edit: added a hint for a common error when using use_navigate by @sjud in #1063
- Remove LeptosProvider trait and use Axum SubStates by @benwis in #1085
- fix: missing
?
in navigation now that it is removed on browser side to match server by @gbj in #1092 - feat: add
<Await/>
component to improve ergonomics of loadingasync
blocks by @gbj in #1091 - updated axum_database_sessions to axum_session. by @genusistimelord in #1090
- Improve fetch example by @anacrolix in #1096
- fix: duplicate headers (like Set-Cookie) on the a...
`v0.3.1`
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.
`v0.3.0`
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.)
New Features and Small Fixes
General
- No longer necessary to import
__Props
types for components; you can justuse app::MyComponent;
instead ofapp::{MyComponent, MyComponentProps};
#[slot]
syntax to define typed component children.- Typed events in
window_event_listener
- Optional event listeners with
HtmlElement::optional_event
- Adds
style:
syntax in theview
macro to set individual styles, much likeclass:
sets individual classes - Simplify work with resources by adding a
Resource::update
method to reactively update current value. expect_context::<T>(cx)
shorthand foruse_context::<T>(cx).unwrap()
Server
- Support for server functions that use
GET
requests (with either URL or CBOR encoding), for easier caching. extract
helper to directly use Actix extractors in a server function.- Allow more complex data like structs and
Vec<_>
as server function arguments (anything that can be de/serialized byserde_qs
) - Support for rendering a
<Route/>
in response to additional HTTP methods/verbs, e.g., the classic PHP/multi-page-app style in which aPOST
request can be sent to a page and it will render a response. (Seemethods
prop.) - Support for
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.
Developer Experience and Ergonomics
- Top-to-bottom integration with the
tracing
crate - Adding some "real-time docs" via several runtime warnings and compile-time errors to prevent common bugs (for example, using
leptos_meta
with no features enabled or accidentally ending theview
a component returns with a semicolon, meaning it renders nothing)
Performance
- Improve performance of Axum integration by spawning requests into a local threadpool.
- Improve performance of router on the server side by caching branch generation.
- Performance improvements in the reactive system and renderer, and closing a memory leak in
<Suspense/>
/<Transition/>
.
And as always...
- Lots of bug fixes! Full changelog below.
Breaking Changes
&'a str
can no longer be directly rendered as a view: add.to_string()
to effected variables. (Previously, all&str
were converted toString
by the renderer; usingCow<'static, str>
now allows&'static str
to be rendered without the additional allocation, at the cost of requiring the conversion of&str
toString
to be more explicit.)window_event_listener
now takes a typed event (likeev::keypress
). Usewindow_event_listener_untyped
for the old behavior.- When deriving
Params
to use typed router search/params, theFromStr
error for any type needs to beSend + Sync
so they areErrorBoundary
compatible - Generics in
create_slice
have changed to allow different input types for getter/setter; only relevant if (for some reason?) you were specifying them manually. - Exact interfaces for a few public-but-rarely-needed functions in the server integrations have changed.
What's Changed
- Fix server functions default macro on stable by @Demonthos in #784
- docs: add runtime "strict mode" checks that warn if you’re non-reactively accessing a value by @gbj in #786
- fix: warnings about untracked signal access in
<Router/>
by @gbj in #790 - Remove unused fs dependency from leptos_config by @valeth in #787
- fix:
untrack
should disable warnings about untracked reads by @gbj in #791 - fix: nested
<Suspense/>
by @gbj in #781 - docs:
<Form/>
component by @gbj in #792 - Fix server functions with non-copy server contexts by @Demonthos in #785
- fix: unused warning on cx in server functions by @markcatley in #794
- docs: warn if you are using
leptos_meta
without features by @gbj in #797 - fix: warning in Cargo.toml by @markcatley in #800
- feat: Add ability to include options to event listeners by @Ofenhed in #799
- fix: fixes #802 as a temporary measure without resorting to #803 yet by @gbj in #804
- fix: prevent router panic on root-level
<Redirect/>
during route list generation by @gbj in #801 - Reduce size of RuntimeId when slotmap is not used by @novacrazy in #805
- fix: unused warning in reactive signal diagnostics by @markcatley in #807
- Add the ability for server fns to be submitted via GET requests by @benwis in #789
- chore: fix unused variable warning in property now that it's not memoized by @gbj in #810
- Optimize Runtime::mark_dirty by @novacrazy in #808
- Optimize memory usage of update methods by @novacrazy in #809
- fix: correctly escape HTML special characters in text nodes during SSR by @gbj in #812
- Publish book ci by @bram209 in #817
- remove
Leptos guide
link by @bram209 in #818 - docs: add sandbox links and max height by @gbj in #824
- fix: correctly pass server fn errors to client by @gbj in #822
- fix: server functions with
url
as argument name (closes issue #823) by @gbj in #825 - chore: deny warnings on github actions by @markcatley in #814
- Use local pools for axum handlers by @akarras in #815
- tests: update benchmarks by @gbj in #827
- feat: make
__Props
imports unnecessary (closes #746) by @gbj in #828 - Various optimizations, size reductions and stability improvements by @novacrazy in #831
- Fix leaked memo nodes by @novacrazy in #841
- [Fix] Correct broken
MaybeSignal
link by @hoangph271 in #840 - feat:
rustls
feature forreqwest
and any other relevant dependencies by @gbj in #842 - fix: don't entity-encode HTML special characters inside
<script>
or<style>
(closes #837) by @gbj in #846 - feat: allow multiple HTTP request methods/verbs by @gbj in #695
- [WIP] Trigger prototype by @novacrazy in #838
- fix static text nodes with curly braces in SSR by @gbj in #849
- docs: emit error when trying to combine global class and dynamic class in a bugged way by @gbj in #850
- fix: custom events in SSR mode by @gbj in #852
- fix: Strip
&
from the end of params queries by @mondeja in #854 - fix: match statement in leptos book by @chroth7 in #860
- Fix the counter without macros test by @agilarity in #863
- feat: add ability to set
node_ref
and pass additional attributes to<Form/>
and friends by @gbj in #853 - Fixed typo in life cycle docs by @Stackingttv in #869
- examples: fix error handling in fetch example by @gbj in #870
- feat: add the ability to specify animations on route transitions by @gbj in #736
- [fix] updated nix flakes lock files on session auth axum examples by @mustafasegf in #872
- docs: Add per-project toolchain override readme by @kamilogorek in #876
- feat: add non-animation base classes to
<AnimatedOutlet/>
and<AnimatedRoutes/>
by @gbj in #877 - Use override key, if available, for server function calling by @snapbug in #878
- feat: add
expect_context
function by @markcatley in #864
-...
`v0.2.5`
v0.2.5
This update includes many bug fixes and documentation improvements, along with a few new features:
- A
<ProtectedRoute/>
component that allows you to create route guards to either render or redirect away from a route depending on some condition. - The ability to add arbitrary attributes to the
<Html/>
and<Body/>
components inleptos_meta
. - Additional head data injected using
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.
What's Changed
- chore: fix clippy warnings by @gbj in #721
- chore: make
wasm-bindgen
dependency optional inleptos_reactive
by @gbj in #723 - chore: Upgrade
console_log
dependency to stable by @mondeja in #724 - fix: relative routing should update when navigating between
<Outlet/>
s (closes issue #725) by @gbj in #729 - fix: include query params in navigation when
<ActionForm>
response redirects. by @andrew-chang-dewitt in #728 - docs: fix typo in router docs by @gbj in #730
- avoid panic in counter_isomorphic Multi-User counter by @mwcz in #732
- leptos-reactive: Bumped serde-lite from 0.3 to 0.4. by @martinfrances107 in #737
- fix: always run individual classes after the
class
attribute (closes #735) by @gbj in #738 - Fix typo in docs. by @grandafrato in #739
- docs: fix typo in server_fn docs by @isti115 in #740
- Document cargo workspace feature resolver footgun by @jmintb in #745
- docs: warn when reading resource outside
<Suspense/>
(closes issue #742) by @gbj in #743 - fix: correct typecast on
Memo::get_untracked
(closes issue #754) by @gbj in #755 - examples: improve
counter_without_macros
by @gbj in #751 - Add
is_mounted
anddyn_classes
by @jquesada2016 in #714 - Fix a few typos by @bnzone in #756
- Add property field to Meta tag by @benwis in #759
- Allow component decl without
use leptos::*
in scope by @lpotthast in #748 - fix: escape
</script>
and other HTML tags in serialized resources by @gbj in #763 - added the id attribute to the Leptos router A tag by @Houski in #770
- fix:
<Redirect/>
between nested routes at same level by @gbj in #767 - fix: prevent forms from entering infinite loops (closes issue #760) by @gbj in #762
- fix: stop memoizing properties in a way that breaks
prop:value
(closes #768) by @gbj in #772 - example: proxy settings to work on all OS by @Kaszanas in #771
- feat: Added ProtectedRoute component to route file by @Kaszanas in #741
- change: insert
<head>
metadata tags at the beginning of the<head>
by @gbj in #731 - docs: fixed parentheses and formatting issues by @luoxiaozero in #775
- Add arbitrary attributes to Html meta tag by @step4 in #726
- chore: clippy and docs warnings by @gbj in #779
- docs: warn if you put something invalid inside
<Routes/>
by @gbj in #780
New Contributors
- @mondeja made their first contribution in #724
- @andrew-chang-dewitt made their first contribution in #728
- @mwcz made their first contribution in #732
- @grandafrato made their first contribution in #739
- @isti115 made their first contribution in #740
- @jmintb made their first contribution in #745
- @bnzone made their first contribution in #756
- @lpotthast made their first contribution in #748
- @Houski made their first contribution in #770
- @Kaszanas made their first contribution in #771
- @luoxiaozero made their first contribution in #775
- @step4 made their first contribution in #726
Full Changelog: v0.2.4...v0.2.5