Introducing Momenta: JSX-like for Rust

⚓ Rust    📅 2025-08-17    👤 surdeus    👁️ 5      

surdeus

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!

1 post - 1 participant

Read full topic

🏷️ Rust_feed