Introducing Momenta: JSX-like for Rust

TL;DR: Lightweight JSX-like syntax for Rust with signals and components.

I started Momenta while porting my portfolio from Next.js to Rust. Momenta provides JSX familiarity + Rust type safety + composable primitives without hook complexity. Good for SSR, static sites, or clean HTML generation.

Features:

  • JSX-like syntax with Rust expressions
  • Custom components with props
  • Signals for reactive state management
  • Scope-aware primitives (no hook complexity)
  • Conditional rendering: {when!(show => <p>Hello</p> else <p>Hidden</p>)}
  • Server-side rendering
  • Fragment support: <></>

Example:

use momenta::prelude::*;

let count = 42;
let items = &["Item 1", "Item 2", "Item 3"];

let html = rsx!(
    <html>
        <body>
            <div class="container">
                <h1>Count: {count}</h1>
                {when!(count > 10 => 
                    <p>That's a lot!</p> 
                    else 
                    <p>Just getting started</p>
                )}
                <ul>
                    {items.iter().map(|item| rsx!(<li>{item}</li>))}
                </ul>
            </div>
        </body>
    </html>
);

println!("{}", html.to_string()); // works fine on server side

Status

  • Core JSX syntax
  • Expressions, conditionals, loops
  • Custom components with props
  • Signals for reactive state
  • Scope-aware primitives
  • Server-side rendering

Links:

[dependencies]
momenta = "0.2"

I would really appreciate any and all feedbacks too.
Thanks!

4 Likes

This is really nice, as I haven't seen a viable React JSX project for Rust until now.

1 Like

This is precisely why I started momenta. I was able to easily port my portfolio for instance and only make changes with Rust specific nuances like conditionals and list rendering

It works with SVG as well, doesn't it?

@ProgramCrafter it works with Svg as well. Although not yet feature complete.

2 Likes

Thanks for making Momenta. I'm looking for a Rust JSX-like library to make a web app with server-side rendering and HTMX. I like Momenta's API. I'm hesitant to use it because it is new and it seems to have minimal test coverage.

Do you plan to add more tests and publish the test coverage percentages?

Also, do you plan to add some co-maintainers? Rust has a lot of unmaintained JSX-like libraries.

Do you plan to add more tests and publish the test coverage percentages?

Yes this is in the works. I'm currently working on stabilizing the API and in the process adding more tests.

And as for co-maintainers, I'm very open to this If anyone shows interest