Skip to main content

Yew 0.22 - For Real This Time

· 3 min read
Mattuwu
Maintainer of Yew

The Yew team is thrilled to announce the release of Yew 0.22! After a longer-than-expected journey, this release brings significant improvements to ergonomics, performance, and developer experience.

Highlights

New #[component] Attribute

The #[function_component] attribute has been renamed to #[component] for brevity:

// Before
#[function_component]
fn MyComponent() -> Html {
html! { <div>{"Hello!"}</div> }
}

// After (0.22+)
#[component]
fn MyComponent() -> Html {
html! { <div>{"Hello!"}</div> }
}

The old #[function_component] attribute is deprecated but still works, giving you time to migrate.

For-Loops in html!

You can now use for-loops directly in the html! macro, making iteration more natural:

// Before - using iterator adapters
html! {
<ul>
{ for items.iter().map(|item| html! { <li>{ item }</li> }) }
</ul>
}

// After (0.22+) - native for-loop syntax
html! {
<ul>
for item in items {
<li>{ item }</li>
}
</ul>
}

MSRV Raised to 1.84.0

The minimum supported Rust version is now 1.84.0. This allows us to use newer language features and provide better error messages.

WASI Support for SSR

Server-side rendering now works on WASI targets. See the original 0.22 announcement for details.

Better Cloning Ergonomics

  • ImplicitClone is implemented for more yew types. This means less & and * and .clone() clutter in the html macro.

yew-agent: Vendored gloo-workers

The yew-agent crate now includes its own web worker implementation, removing the external dependency on gloo-worker. This also adds support for module-type web workers:

let spawner = WorkerSpawner::<MyWorker>::new()
.as_module(true) // Use ES module workers
.spawn();

yew-router: Query Parameter Traits

The FromQuery and ToQuery traits from gloo are now re-exported via yew_router::query for more flexible query parameter handling, along with dynamic basename support.

Migration Guide

See the migration guide for detailed instructions on upgrading from 0.21.

Contributors

Many thanks to everyone who contributed to this release! Special thanks to:

And all the other contributors who helped make this release possible!

What's Next

We're continuing to work on improving Yew's performance, developer experience, and documentation. Join us on Discord to get involved!

See the full changelog for all changes.