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:
Make an app#
&& 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.
⌘Zundoes 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 browsersEdit 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:
app!; // a server, storing its model's events
app!; // a server, storing its own state
app!; // local-first, in each person's browser
app!; // static, every page rendered at build time| Server | Local-first | Static | |
|---|---|---|---|
| Runs | A program you deploy | In each person's browser (a service worker) | At build time, into files |
| Keeps | Events in SQLite or Postgres, or your own state with plain | Each space's history, encrypted, synced through a store that can't read it | Nothing: it reads Markdown and data as it builds |
| Includes | History, per-person undo, presence, live pages | Accounts, passkeys, sharing, sync, undo, offline | Per-page titles and descriptions, a 404 page, a sitemap |
| Start | soda new launch | soda new --local launch | soda new --static atlas |
| Deploy | soda deploy: a container image, or a Docker host | soda deploy: published with Vercel | soda 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#
| Command | Does |
|---|---|
soda new <dir> | Makes an app: --local, --static, --plain |
soda dev | Serves it, patching in each change |
soda check | Tests, Clippy, and the design-token check |
soda test | check, then a build and the end-to-end tests |
soda build | Builds into dist/ |
soda deploy | Ships it |
soda events | Shows or exports what an app's store keeps |
soda load | Measures 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.