Please note: This framework is in active development. I'm keeping it in a cycle of 0.0.x releases at the moment to indicate that it’s not even ready for its 0.1.0. Active work is being done on documentation and features, and APIs should not necessarily be considered stable. At the same time, it is more than a toy project or proof of concept, and I am actively using it for my own application development.

Leptos Logo

crates.io docs.rs Discord

Leptos

```rust use leptos::*;

[component]

pub fn SimpleCounter(cx: Scope, initialvalue: i32) -> Element { // create a reactive signal with the initial value let (value, setvalue) = createsignal(cx, initialvalue);

// create event handlers for our buttons
// note that `value` and `set_value` are `Copy`, so it's super easy to move them into closures
let clear = move |_| set_value(0);
let decrement = move |_| set_value.update(|value| *value -= 1);
let increment = move |_| set_value.update(|value| *value += 1);

// this JSX is compiled to an HTML template string for performance
view! {
    cx,
    <div>
        <button on:click=clear>"Clear"</button>
        <button on:click=decrement>"-1"</button>
        <span>"Value: " {move || value().to_string()} "!"</span>
        <button on:click=increment>"+1"</button>
    </div>
}

}

// Easy to use with Trunk (trunkrs.dev) or with a simple wasm-bindgen setup pub fn main() { mounttobody(|cx| view! { cx, }) }

```

About the Framework

Leptos is a full-stack, isomorphic Rust web framework leveraging fine-grained reactivity to build declarative user interfaces.

What does that mean?

Learn more

Here are some resources for learning more about Leptos:

FAQs

Is it fast?

The gold standard for testing raw rendering performance for front-end web frameworks is the js-framework-benchmark. I'm waiting for the next round of official results before making claims about performance here, but the unofficial results (which you can see if you check out master from the benchmark repo and open the results page) have Leptos as the fastest Rust/Wasm framework, on this benchmark.

How is this different from Yew/Dioxus?

On the surface level, these libraries may seem similar. Yew is, of course, the most mature Rust library for web UI development and has a huge ecosystem. Dioxus is similar in many ways, being heavily inspired by React. Here are some conceptual differences between Leptos and these frameworks:

How is this different from Sycamore?

Conceptually, these two frameworks are very similar: because both are built on fine-grained reactivity, most apps will end up looking very similar between the two, and Sycamore or Leptos apps will both look a lot like SolidJS apps, in the same way that Yew or Dioxus can look a lot like React.

There are some practical differences that make a significant difference:

```rust let (count, setcount) = createsignal(cx, 0); // a signal let doublecount = move || count() * 2; // a derived signal let memoizedcount = creatememo(cx, move || count() * 3); // a memo // all are accessed by calling them asserteq!(count(), 0); asserteq!(doublecount(), 0); asserteq!(memoized_count(), 0);

// this function can accept any of those signals fn doworkonsignal(mysignal: impl Fn() -> i32) { ... } ```