Momenta
Simple and performant reactivity for building user interfaces
A fine-grained reactive framework for Rust that makes it simple to build high-performance, reactive user interfaces using Rust's type system and ownership model.
use *;
Features
Element-Level Reactivity
Fine-grained reactivity that automatically tracks dependencies and updates only what has changed.
Type-Safe Components
Leverage Rust's type system for compile-time guarantees and better developer experience.
Lightweight & Fast
Small runtime with minimal overhead. Your apps stay fast and bundle sizes stay small.
Familiar API
Inspired by React with a Rust-first approach to reactive programming.
SSR Ready
Server-side rendering support out of the box with a simple API for better performance and SEO.
Composable Primitives
Build complex UIs from simple, reusable reactive primitives:
- Signals - Fine-grained reactive state
- Computed Signals - Derived values with automatic memoization
- Effects - Side effect management
- Resources - Async data loading with built-in loading/error states
Quick Start
Add Momenta to your Cargo.toml:
[]
= "0.2"
Create your first component:
use *;
Why Momenta?
I started this project while attempting to transit my portfolio from Next.js to Rust. I tried using dioxus, yew, and hypertext, but I found them to be too complex and verbose for my needs. I wanted a simple and intuitive way to write HTML-like templates in Rust, while still leveraging the full power of Rust's type system.
Momenta aims to provide:
- Simplicity - Easy to learn, easy to use
- Performance - Fine-grained reactivity means minimal updates
- Type Safety - Leverage Rust's type system for compile-time guarantees
- Familiarity - React-like API that's easy to pick up
Core Concepts
Signals - Reactive State
let count = create_signal;
count.set; // Set value
let value = count.get; // Get value
count += 1; // Update with operators
Computed Signals - Derived Values
let count = create_signal;
let doubled = create_computed;
// or use the derive method
let tripled = count.derive;
Effects - Side Effects
create_effect;
Resources - Async Data
let user = create_resource;
rsx!
Components - Reusable UI
Control Flow - Conditionals & Lists
// Conditional rendering
// List rendering
let items = create_signal;
rsx!
Documentation
- Getting Started Guide - Learn the basics
- API Documentation - Complete API reference
Feature Flags
Enable optional features in your Cargo.toml:
[]
= { = "0.2", = ["full-reactivity"] }
Available features:
dom- All HTML elements with DOM rendering (default)wasm- WebAssembly support for browser rendering (default)computed- Computed signals supportmemoization- Memoization utilitiesfull-reactivity- All reactive features (includes computed + memoization, default)
For server-side rendering without DOM, use only momenta-core:
[]
= "0.2"
Community & Support
- GitHub Discussions - Ask questions, share ideas
- Issues - Report bugs, request features
- Contributing Guide - Learn how to contribute
Contributing
We welcome contributions! Here's how you can help:
- Report bugs - Open an issue with a minimal reproduction
- Suggest features - Start a discussion about your idea
- Improve docs - Help us make the docs better
- Submit PRs - Fix bugs or implement features
Please read our Contributing Guide before submitting PRs.
Comparison with Other Frameworks
| Feature | Momenta | Yew | Dioxus |
|---|---|---|---|
| Fine-grained reactivity | Yes | No | Yes |
| JSX-like syntax | Yes | Yes | Yes |
| SSR Support | Yes | Yes | Yes |
| Learning curve | Low | Medium | Medium |
| Bundle size | Small | Large | Medium |
License
MIT License - see LICENSE for details