Learn by making

Small examples.
Real foundations.

Follow the state. See how the pieces fit.
The same Rust views, running in two places.

i

Install the CLI once. Run Counter and Chat from your Refract checkout. The CLI handles WASM setup and rebuilds on save. Native examples have been tested on macOS. Set up once →

01 /

Counter

A tiny application. A reactive foundation.

Start here

Declare a value, read it in a view, and update it from an action. This is the smallest useful loop in Refract.

counter.rs · simplified view
use refract::prelude::*;

#[view]
fn counter(cx: &mut ViewContext<'_>, initial: u32) -> impl View {
    #[state]
    let count: u32 = initial;

    #[action(count)]
    let increment = |cx| {
        count.update(cx.runtime(), |n| *n += 1);
    };

    view()
        .child(text(format!("Count: {}", cx.read(&count))))
        .padding(16.0)
        .on_press(increment)
}
Run the counter
refract dev -p refract-counter --open
02 /

Chat

Async replies. A responsive UI.

Searchable conversations, per-chat drafts, and local replies streamed through typed channels. Native worker threads and browser async tasks produce chunks; UI-side receivers update state. Replies continue when you switch chats, while Stop or deletion cancels their work. Replies are scripted, need no API key, and stay in this session.

  • ↳Async work
  • ↳Typed channels
  • ↳Scoped cancellation

Refract checkout
examples/chat/src/lib.rs

Run Chat
refract dev -p refract-chat --port 4176 --open
Try the live app
03 /

Block Editor

Rich text. Your own workspace.

Write with headings, lists, and tables. Format text, select across blocks, and undo edits. A Yrs document holds the content while Refract updates the affected fields. Each visitor gets a local workspace, with edits saved in their browser and no shared server.

  • ↳Text editing
  • ↳Selection & clipboard
  • ↳Local persistence
Try the live app

Make it your own

Start building today.

Stacks, spacing, and paint are just Rust method calls. Start from an example, change a view, and build up from there.

Explore layout & styling
Your next view
v_stack()
    .gap(16.0)
    .child(text("Hello, Refract").font_size(28.0))
    .child(text("A shared view. A different host."))
    .padding(24.0)
    .background(Color::rgb(15, 30, 52))
    .foreground(Color::WHITE)
    .radius(12.0)