Concepts
Understand how Cuttlefish works and what makes it powerful.Live SQL
When you writeuseLiveQuery("SELECT * FROM todos"), you’re writing Live SQL - standard SQL queries that automatically update your UI when data changes.
What’s happening: Live Partial Replica
Behind the scenes, Cuttlefish builds a Live Partial Replica of your database in the browser. When you run a live query:- Cuttlefish Engine (server) executes your SQL against Postgres
- Initial data is sent to the browser and stored in RowCache (normalized, in-memory storage)
- Subsequent changes stream to the browser in real-time via WebSocket
- QueryEvaluator runs your query against the local RowCache
- React re-renders with fresh data
Why it’s powerful: Normalized Replication
Here’s what makes Cuttlefish different from other real-time solutions: it sends normalized relations, not denormalized projections.Example: Messages with user names
Most real-time tools:Why does this matter?
With denormalized data, if you want to filter messages differently (e.g., by read status), you need a new server query - the data isn’t structured for it. With Cuttlefish’s normalized RowCache, the data is already there. Filter by status, user, date - all instant. No new server queries. This is what enables the Composable Sync pattern.Unlocking more: Composable Sync
The normalized replica enables a powerful pattern: Composable Sync - “replicate once, query infinitely.”Two ways to query
Pattern 1: The convenient wayZero loading states everywhere
Once you’ve replicated data, every interaction is instant:Filtering and search
Page navigation
Sorting
Switching views
The pieces: Engine and Client
Cuttlefish is built from two pieces that work together:Cuttlefish Engine (server)
- Executes SQL against Postgres
- Performs normalized replication
- Streams changes via WebSocket
- Language-agnostic - use from Python, Go, Ruby, or any language
Client packages (browser)
@cuttlefish-sync/core- RowCache, QueryEvaluator, protocol types@cuttlefish-sync/react- React hooks (useLiveQuery,useLocalLiveQuery,replicateQuery)@cuttlefish-sync/kysely- Kysely adapter for type-safe queries@cuttlefish-sync/raw-sql- Raw SQL tagged template adapter