Yew (Rust): WebAssembly Frontend Framework vs Leptos

Max WellsMax WellsFounder of Rustify

TL;DR: Yew is a React-inspired Rust framework for building web UIs that run as WebAssembly in the browser. You write components with a html! macro (similar to JSX), manage state with hooks (use_state, use_effect), and compile to WASM with wasm-pack or trunk. Yew was the first major Rust frontend framework and has a large community. For a more modern alternative with fine-grained reactivity and full-stack support, consider Leptos or Dioxus.


What Is Yew?

Yew is a Rust framework for building Single Page Applications (SPAs) that compile to WebAssembly.

[dependencies]
yew = { version = "0.21", features = ["csr"] }

Components are Rust functions or structs decorated with #[function_component]. The html! macro renders HTML with Rust expressions interpolated.


How Do You Write a Yew Component?

Function components use hooks for state and the html! macro for rendering.

use yew::prelude::*;
 
#[function_component(Counter)]
fn counter() -> Html {
    let count = use_state(|| 0);
 
    let increment = {
        let count = count.clone();
        Callback::from(move |_| count.set(*count + 1))
    };
 
    html! {
        <div>
            <p>{ format!("Count: {}", *count) }</p>
            <button onclick={increment}>{ "Increment" }</button>
        </div>
    }
}
 
#[function_component(App)]
fn app() -> Html {
    html! { <Counter /> }
}
 
fn main() {
    yew::Renderer::<App>::new().render();
}

How Do You Handle Props and Callbacks?

Define a Properties struct and pass values between parent and child components.

#[derive(Properties, PartialEq)]
pub struct ButtonProps {
    pub label: String,
    pub on_click: Callback<MouseEvent>,
}
 
#[function_component(MyButton)]
fn my_button(props: &ButtonProps) -> Html {
    html! {
        <button onclick={props.on_click.clone()}>
            { &props.label }
        </button>
    }
}

Yew vs Leptos vs Dioxus in 2026

Yew is React-like with virtual DOM. Leptos uses fine-grained signals. Dioxus offers cross-platform targets.

YewLeptosDioxus
MaintainerYew communityGreg JohnstonDioxusLabs
ReactivityVirtual DOMFine-grained signalsSignals
SSR supportLimited (experimental)✅ Full-stack✅ dioxus-fullstack
TargetsWeb (WASM)Web + ServerWeb, Desktop, Mobile
MaturityOldest (2019)Newer (2022)Newer (2021)
Current version0.210.70.6
React similarityHighMediumHigh

If you are migrating a React application or your team already knows React patterns deeply, Yew 0.21 is the most natural Rust frontend choice. If you need SSR, SEO-friendly rendering, or a full-stack Rust app, choose Leptos instead. If you need to ship to desktop or mobile alongside the browser, choose Dioxus.


Frequently Asked Questions

Yes. Yew 0.21 is actively maintained with regular releases. While it is no longer the only major Rust frontend framework, its large community and extensive ecosystem of tutorials make it a reliable production choice for browser-only applications.

Use gloo-net (the recommended async HTTP client for WASM) or reqwest with the wasm feature. Call them inside use_effect or spawn_local.

Use trunk; it watches for changes, compiles WASM, and serves the app locally. Run trunk serve during development, trunk build --release for production.

Yew has experimental SSR support, but it is less mature than Leptos. For full-stack Rust apps with SSR, Leptos is the more production-ready choice in 2026.

use_state is a simple value holder with a setter, equivalent to React's useState. use_reducer is for more complex state transitions where you dispatch actions; equivalent to React's useReducer. For most components, use_state is sufficient.


Sources


  • wasm: Yew compiles to WebAssembly
  • leptos: The modern alternative to Yew with fine-grained reactivity
  • dioxus: Cross-platform alternative (web, desktop, mobile)
  • macro: The html! macro is the core of Yew's template syntax
  • async-await: Yew uses async for HTTP requests via spawn_local
  • serde: Used to deserialize API responses in Yew data fetching
  • wasm-bindgen: Yew's browser interop is built on top of wasm-bindgen's binding layer

When Should You Choose Yew in 2026?

Yew is the right choice when your team wants the shortest migration path from React and does not need server-side rendering or native desktop targets.

Its virtual DOM model, hook system (use_state, use_effect, use_context), and JSX-like html! macro map almost directly to React idioms. Teams that have React experience can be productive in Yew within hours rather than days. The trade-off is performance: virtual DOM diffing is slower than Leptos's fine-grained signal updates, and Yew's SSR story remains experimental in 2026; you get a SPA, not a full-stack framework. For browser-only SPAs where React familiarity matters and SSR is not a requirement, Yew 0.21 remains a solid, production-tested foundation with thousands of GitHub stars and an active community.


Keep Reading

Ready to Land a $80-120k Rust Job?