Getting started

Soda is a web framework for Rust, built on Datastar. If you know SvelteKit or Next.js, you know its shape:

  • Routes are folders.
  • Pages are view! markup, made of components.
  • Forms post to typed actions.
  • Tailwind styles everything, through design tokens.

A page reads what it needs and renders. An action changes something, and every open page renders again. There are no loaders, caches or client state to sync.

Install#

You need Rust, through rustup, and Node 22. Each app pins its Rust toolchain in rust-toolchain.toml, and rustup fetches it the first time.

Then install the soda command from a checkout of the repository:

cargo install --path cli

Make an app#

soda new launch
cd launch && soda dev    # http://localhost:5180

The app's name comes from its folder (family-pantry is Family Pantry). To pick another, give it as a second argument: soda new launch "Launch Plan".

You get a working Kanban board, with its tests passing. Every change on it is kept as an event:

  • Live. Open it in two browsers and move a card. It moves in both, and each 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 still there.
launch/
  events.lock            the events' shapes (they can only grow)
  src/
    main.rs              soda_server::app!(board::Board)
    board.rs             the model: events, rules, undo
    components.rs        shared components
    routes/
      layout.rs          wraps every page
      page.rs            /
      actions.rs         what the forms post to
      log/page.rs        /log
  web/app.css            the design tokens
  web/kit.js             browser code (components go in web/components/)
  tests/e2e.mjs          end-to-end tests in real browsers

Edit a page and save. soda dev patches the change into the running app in about a second, and the page re-renders in place: your scroll, the form you were typing in and the server's data all stay. Events explains the model.

Choose a backend#

The backend is where an app runs. Routes, pages, components and layouts are the same on every backend. You pick one in src/main.rs:

soda_server::app!(board::Board);       // a server, storing its model's events
soda_server::app!(plain list::List);   // a server, storing its own state
soda_local::app!(model::Items);        // local-first, in each person's browser
soda_static::app!(site::Site);         // static, every page rendered at build time
ServerLocal-firstStatic
RunsA program you deployIn each person's browser (a service worker)At build time, into files
KeepsEvents in SQLite or Postgres, or your own state with plainEach space's history, encrypted, synced through a store that can't read itNothing: it reads Markdown and data as it builds
IncludesHistory, per-person undo, presence, live pagesAccounts, passkeys, sharing, sync, undo, offlinePer-page titles and descriptions, a 404 page, a sitemap
Startsoda new launchsoda new --local launchsoda new --static atlas
Deploysoda deploy: a container image, or a Docker hostsoda deploy: published with Vercelsoda deploy: published with Vercel

Add --plain to a server or local-first app to start from a simple checklist instead of the board. The board's model (src/board.rs) is the same on a server and local-first; local-first adds a LocalFirst impl that names what a space is called. For a local-first app, --noun pantry sets that name (--plural if English's plural is wrong).

A static site has no actions. When it needs some, move its pages to a server or local-first app.

Commands#

CommandDoes
soda new <dir>Makes an app: --local, --static, --plain
soda devServes it, patching in each change
soda checkTests, Clippy, and the design-token check
soda testcheck, then a build and the end-to-end tests
soda buildBuilds into dist/
soda deployShips it
soda eventsShows or exports what an app's store keeps
soda loadMeasures a server app under many people at once

Next#

  • Tutorial: build a guestbook on a server, step by step.
  • Events: the model behind soda new, with history and undo.
  • Local-first: build Pantry, an app that runs in the browser.
  • Static sites: build a site from Markdown.
  • Reference: everything an app writes.

This page is docs/getting-started.md in the SDK, built into this site as it is.

Esc