Triplit is a full-stack database that syncs data between server and client in real-time. It combines the local-first approach with a full query engine that works identically on client and server.
What Makes Triplit Special?
- Full query engine on client — complex queries run locally
- Real-time sync — automatic, conflict-free replication
- Offline support — full app works without connection
- Schema enforcement — type-safe on client and server
- Free tier — self-host or use Triplit Cloud
The Hidden API: Synced Queries
import { TriplitClient } from '@triplit/client';
const client = new TriplitClient({
serverUrl: 'https://your-app.triplit.io',
token: 'your-token',
schema: {
todos: {
schema: S.Schema({
id: S.Id(),
title: S.String(),
completed: S.Boolean({ default: false }),
assignee: S.String(),
dueDate: S.Date(),
priority: S.Number({ default: 0 })
})
}
}
});
// Subscribe to live queries — updates in real-time!
const unsubscribe = client.subscribe(
client.query('todos')
.where('completed', '=', false)
.where('assignee', '=', currentUser.id)
.order('priority', 'DESC')
.limit(20),
(results) => {
console.log('My tasks:', results);
updateUI(results);
}
);
// Write data — syncs to all clients automatically
await client.insert('todos', {
title: 'Ship feature',
assignee: currentUser.id,
priority: 1,
dueDate: new Date('2026-04-01')
});
React Integration
import { useQuery } from '@triplit/react';
function TaskList() {
const { results: tasks, fetching } = useQuery(
client,
client.query('todos')
.where('completed', '=', false)
.order('priority', 'DESC')
);
if (fetching) return <Loading />;
return tasks.map(task => (
<TaskCard
key={task.id}
task={task}
onComplete={() => client.update('todos', task.id, (t) => { t.completed = true; })}
/>
));
}
Quick Start
npm create triplit-app
cd my-app && npm run dev
Why Teams Choose Triplit
A developer shared: "We were using Firebase and writing complex sync logic for offline support. Triplit gave us offline-first, real-time sync, and relational queries out of the box. We deleted 2,000 lines of sync code."
Building synced apps? Email spinov001@gmail.com or check my developer tools.
How do you handle client-server sync? Triplit vs Firebase vs Convex?
Top comments (0)