Ablo(...),
and every actor gets the same typed model surface:
- typed model clients in trusted server runtimes,
- React selectors through
useAblo((ablo) => ablo.<model>.get(id)), - agent and background-worker writes,
- Data Source request/response shape when your database stays canonical,
- hosted schema push, migration planning, and schema-version gating.
Minimal shape
weatherReports) becomes the client namespace
(ablo.weatherReports). The Zod fields become the create/update/read type
contract. You should not create a parallel string-keyed write path for the same
data.
Reserved fields
The SDK provides these on every row automatically — do not declare them in yourmodel(...) fields:
idcreatedAtupdatedAtorganizationIdcreatedBy
Reads and writes
Use async reads when the row may not be local:Coordination
Agents and background jobs often read, call a tool or model, then write later. Wrap that slow span inclaim:
claim waits, re-reads, and hands you
the fresh row. Reads stay open; only acting on the row serializes.
Storage boundary
Every schema model is backed by your own database. There are three start states, all covered in Connect Your Database (the single source of truth): the sandbox (apiKey only, no database), a direct connection string
(databaseUrl passed to Ablo(...), a live, server-only option), or a signed
Data Source endpoint where your app keeps the database credential and commits
each write itself.
If your database stays canonical behind a Data Source endpoint, do not pass
databaseUrl to Ablo(...) — trusted runtimes use ABLO_API_KEY. Browser code
goes through <AbloProvider> or a scoped session route, never a raw API key.
Rules of thumb
- Start with fields and relations before load/index tuning.
- Import one schema into app code, server actions, agents, and Data Source routes.
- Keep direct database writes out of the coordinated path unless they are reported back through Data Source events.
- Use
claimfor slow read -> think -> write spans. - Use
readAt+onStale: 'reject'when a write must fail if the row changed after it was read.