Announcing Momenta v0.3.0 — Fine-grained reactive UI framework with SSR, hydration, and a client-side router

Hi everyone! I'm excited to announce Momenta v0.3.0, a fine-grained reactive framework for building user interfaces in Rust.

Momenta gives you element-level reactivity, JSX-like rsx! templates, and a familiar component model — all backed by Rust's type system and ownership guarantees.

What's new in v0.3.0

Server-Side Rendering & Hydration — The new momenta-ssr crate ships with:

  • render_to_string for buffered HTML output
  • render_to_chunks for streamed/chunked HTML
  • render_to_hydration_string with stable data-momenta-* markers and embedded JSON state for client-side resume
  • Thin adapters for Axum, Actix, and Hyper

Client-Side Router — The new momenta-router crate provides:

  • Hash and pathname routing modes
  • Base path support
  • Automatic link interception for SPA navigation
  • Pattern-based route matching via matchit

Major Performance Improvements — Benchmarked against v0.2.3:

Area Improvement
Effects 99.5% faster (585μs → 2.7μs)
Signal reads 80% faster
Signal updates 58% faster
List rendering (small) 48% faster
Element-to-string 55% faster
List rendering (large) 18% faster
Component with state 22% faster

Other highlights:

  • Improved RSX whitespace handling
  • Better event propagation
  • Optimized HTML writer with minimal allocations
  • Transient scope cleanup for improved DOM rendering

Quick look

use momenta::prelude::*;

#[component]
fn Counter() -> Node {
    let count = create_signal(0);

    rsx! {
        <div class="counter">
            <h1>"Count: " {count}</h1>
            <button on:click={move |_| count += 1}>"Increment"</button>
        </div>
    }
}

fn main() {
    momenta::dom::render_root::<Counter>("#app");
}

SSR with Axum is just as straightforward:

use momenta::prelude::*;
use momenta_ssr::render_to_string;

let html = render_to_string(|| {
    rsx!(<main><h1>"Hello from Momenta SSR"</h1></main>)
});

Links

Feedback, issues, and contributions are very welcome. Thanks for checking it out!

1 Like

Any plans to make a zero dependency version?

This is the plan actualy and momenta is moving towards that angle.

There are some non-negotiables like wasm-bindgen and all but generally yes there's plan to make compiling a momenta powered app super fast.

any plans for a Rocket adapter?

Yes there's plans for Rocket adapter

This project sounds very similar to yew. How would you compare it ?

If I were to compare it, the difference is mostly in syntax and reactivity model.

Yew uses a re-imagined HTML syntax while Momenta aims to be as closely resembling rsx as possible. This is important because it's preety much why I created it in the first place. I wanted to rewrite my portfolio but didnt want to start learnning a new syntax for writing views. In momenta, there's very little difference between the JSX in react and RSX in Momenta. The differences are mostly compiler imposed.

Talking about reactivity model while Yew is component based reactive, Momenta uses fine grained reactivity much like solid and unlike solid, it's element-level updates not precise node-level. So we have the goodness of both worlds.

There's a table that goes deeper into this. You can find here: GitHub - elcharitas/momenta: Simple and performant reactivity for building user interfaces in rust · GitHub

My reading of the LLM in the OP is that this work plagiarises leptos, not yew.

OP:

a fine-grained reactive framework for building user interfaces in Rust.

Leptos:

Rust web framework leveraging fine-grained reactivity to build declarative user interfaces.

I'm not sure why you'd say "plagiarises" since "fine-grained reactivity" isn't a concept unique to Leptos in anyway. Or is there something I'm missing?