Rust on theweb,without thewait.

SvelteKit's shape, in Rust. soda dev patches each change in.

On tap

On a server

soda new launch

A program you deploy, live for everyone.

Local-first

soda new --local pantry

No server: it runs in each person's browser.

Static

soda new --static atlas

Rendered at build time, into files any host serves.

pub async fn page(cx: &Cx) -> Result<View> {    let items = cx.state.items().await?;    Ok(view! {        <form action=Add class="flex gap-2">            <Input name="text" placeholder="Add an item" required />            <Button primary submit>""</Button>        </form>        <ul class="divide-y divide-line">            {items.iter().map(|item| view! { <li>{&item.text}</li> })}        </ul>    })}
Try

soda devwatching src/ and web/

localhost:5180/

Groceries

  • Oat milk
  • Lemons
  • Sourdough

A replay, in your browser. On your machine, soda dev patches your real app: about 0.7 s for a page, a component or an action, 0.3 s for a style.

What you write

A page reads what it needs and renders. An action changes something, and every open page renders again. No loaders, no caches, no client state.

  1. Routes are folders

    A folder is an address, and [item] is a typed param. Links are functions (link::items::item(&id)), so a broken link is a compile error.

    src/routes/
    layout.rs       wraps every page
    page.rs         /
    actions.rs      what its forms post to
    items/[item]/
      page.rs       /items/:item
  2. Pages are view! markup

    JSX-like, escaped, built from components. A component is a function of its props, and a missing prop is a compile error that names it.

    src/components.rs
    #[component]
    pub fn ItemRow(item: &Item) -> View {
        view! {
            <li class="flex gap-3">{&item.text}</li>
        }
    }
  3. Forms post to typed actions

    #[derive(Form)] parses and checks what was sent. An error goes back to its field, and the page keeps what was typed.

    src/routes/actions.rs
    #[derive(Form)]
    pub struct NewItem {
        #[form(max = 500)]
        pub text: String,
    }
    
    #[action]
    pub async fn add(cx: &mut Act, form: NewItem) -> Result {
        cx.state.add(&form.text).await?;
        Ok(()) // every open page renders again
    }
  4. The look is tokens

    One @theme sets the look, Soda's own components included. The build rejects any color, font, radius or shadow that isn't a token.

    web/app.css
    @theme {
      --color-accent: #c8175f;
      --radius-card: 18px;
      --font-display: "Soda Sans";
    }
  5. Datastar underneath.

    Pages are HTML, streamed to the browser and morphed in place. Each open page holds one stream, so a change shows on every page at once. What only a browser can do (local times, live countdowns, drag and drop) is web components, styled by the same tokens.

One command,
a live app

soda new makes a Kanban board built on events. Every change is kept, so it comes with these, already working:

Live
Move a card and it moves in every open browser. Each one shows who's there.
History
Drag the line along the bottom to see the board at any earlier moment.
Undo
⌘Z undoes your own changes, never anyone else's.
Kept
Restart the server and it's all there, in SQLite to start or Postgres to scale.
soda new launchHow events work
Ben's browser: the board's three columns of cards, Ann and Ben in the corner, and the history line along the bottom ending at Ben's last moveAnn's browser, looking back at the third of eight changes: only three cards, all in To do, and a notice saying nothing changes until she comes back
The board soda new makes: Ben's browser, live, and Ann's, looking back at the third change.

One app,
three backends

Routes, pages and components are the same on each. Choosing one is a line in src/main.rs.

// a server, storing its model's events
soda_server::app!(board::Board);
// a server, storing its own state
soda_server::app!(plain list::List);
// local-first, in each person's browser
soda_local::app!(model::Items);
// static, rendered at build time
soda_static::app!(site::Site);

On a server

A program you deploy. It stores your model's events and renders every page from them, live for everyone.

  • History, per-person undo and presence, built in
  • SQLite to start, Postgres for many servers
  • soda deploy builds a container image

soda new launch

Local-first

No server of its own. The app runs in each person's browser; changes are signed and encrypted on the device and sync through a store that can't read them.

  • Accounts, passkeys, sharing and offline, built in
  • Browsers trade changes directly, in about 20 ms
  • Static files, published with Vercel

soda new --local pantry

Static

Every page rendered at build time, into files any host serves: docs, a blog, a landing page. This site is one.

  • A page for each item, from the route's params
  • Per-page titles, a 404 page and a sitemap
  • Vercel, Netlify, GitHub Pages or a bucket

soda new --static atlas

# once, from a checkout of the repository
$ cargo install --path cli
# a live board on events: open it in two browsers
$ soda new launch
$ cd launch && soda dev
  serving http://localhost:5180, patching each change in
Esc