Security & Sync
/
Local-First Sync
Local-First Sync
Opt into local-first replication with one line — optimistic hooks, a changefeed, and a transaction queue.
View as Markdown
llms.txt
A resource opts into local-first replication with sync: { mode: "local", … } in its options. The client runtime — an IndexedDB store, an optimistic transaction queue, and a long-poll changefeed — is generated from the x-rastack-sync OpenAPI extension.
resources/chat.ts
ts · copy
1
export
const
Message
=
resource
(
"chat"
,
"message"
,
{
2
room
:
s
.
ref
(()
=>
Room
),
3
body
:
s
.
string
(),
4
},
{
5
sync
:
{
mode
:
"local"
},
6
});
Optimistic by default
Synced hooks are async and optimistic by default: a mutation applies to the local store immediately and reconciles with the server in the background. Individual operations can opt into blocking ("sync") semantics where correctness demands it — for example, a password change.
The client runtime
Piece
Role
tools/sync/ store
an IndexedDB-backed local copy of each synced table
transaction queue
holds optimistic mutations until the server confirms them
long-poll changefeed
streams server changes back into the local store
! Warning
The client runtime ships today. The server endpoints (/api/sync/v1/{bootstrap,changes}) are being ported to the Rust API; rastack compile already emits x-rastack-sync so the client hooks generate now.
Build with AI
Every page is available as clean Markdown for LLMs and coding agents. Point one at the files below to build on top of React API Stack.
React API Stack · alpha · built to scale to millions