Expand description
§Introduction

Natrix is a Rust-first frontend framework. Where other frameworks aim to bring React-style development to rust, Natrix embraces Rust’s strengths—leveraging smart pointers, derive macros, the builder pattern, and other idiomatic Rust features to create a truly native experience.
§A Simple Example
A simple counter in Natrix looks like this:
#[derive(Component)]
struct Counter(usize);
impl Component for Counter {
fn render() -> impl Element<Self::Data> {
e::button()
.text(|ctx: R<Self>| *ctx.0)
.on::<events::Click>(|ctx: &mut S<Self>, _| {
*ctx.0 += 1;
})
}
}
See the book for more information
§Standout features
- ✅ No macro DSL – Macro-based DSLs break formatting & Rust Analyzer support. Natrix avoids them completely for a smoother dev experience.
- ✅ Derive macros for reactive state – No need for
useSignal
everywhere, state is directly tied to Rust’s type system. - ✅ Callbacks use references to state – Instead of closures capturing state setters, Natrix callbacks take a reference to the state, which better aligns with Rust’s ownership model.
- ✅ Fine-grained reactivity – Natrix only updates what’s necessary, minimizing re-renders and maximizing performance.
- ✅ Smart feature selection - Natrix will automatically use nightly-only optimizations if possible without needing a explicit
nightly
flag. - ✅ Borrow Safety - We only use one
RefCell
per component instance, all other state is managed within the rust borrowing rules, which gives stronger guarantees of no panics as well as performance.
§Design Goals
- Developer experience first – Natrix is designed to feel natural for Rust developers.
- Idiomatic Rust – We use Rust-native features & patterns, not what worked for js.
- Stop porting JS to Rust – Rust is an amazing language, let’s build a frontend framework that actually feels like Rust.
Modules§
- async_
utils - Async utils
- callbacks
- Implementations of various traits for closures.
- component
- Component traits
- element
- Implementation of the
Element
trait for various abstract types. - events
- What kind of event to give to the handlers
- html_
elements - Implemention of html elements, as well as helper constructors.
- prelude
- Public export of everything.
- state
- Types for handling the component state
Macros§
- guard_
option - Get a guard handle that can be used to retrive the
Some
variant of a option without having to use.unwrap
. Should be used to achive find-grained reactivity (internally this uses.watch
on.is_some()
) - guard_
result - Get a guard handle that can be used to retrive the
Ok
variant of a option without having to use.unwrap
, or theErr
variant.
Functions§
- set_
panic_ hook - Set the panic hook to mark that a panic has happened