The fullstack database.
Triplit is an open-source database that syncs data between server and browser in real-time.
npm create triplit-app@latest
Live updating queries
Triplit's queries are reactive by default, so you can build apps that update in real-time without any extra work.
Automatic caching and syncing on the client
Full relational support for querying connected data
Typescript support for all data returned from queries
React Hooks to subscribe to queries in your UI
use-messages.ts
import { useQuery } from "@triplit/react"
import { client } from "@/lib/triplit"
export function useMessages(convoId: string) {
const deliveredMessagesQuery = client
.query("messages")
.where("conversationId", "=", convoId)
.order("created_at", "DESC")
.syncStatus("confirmed")
const {
results: messages,
fetchingRemote,
fetching,
error,
} = useQuery(client, deliveredMessagesQuery)
}
use-messages.ts
import { useQuery } from "@triplit/react"
import { client } from "@/lib/triplit"
export function useMessages(convoId: string) {
const deliveredMessagesQuery = client
.query("messages")
.where("conversationId", "=", convoId)
.order("created_at", "DESC")
.syncStatus("confirmed")
const {
results: messages,
fetchingRemote,
fetching,
error,
} = useQuery(client, deliveredMessagesQuery)
}
“Triplit would be [...] your MongoDB or MySQL, but it’s also your Drizzle, your schema definition and query language. But then it’s also your Tanstack query which you use on the client side. It’s everything.”
Zero downtime
Let your users keep working even when their network connection isn't.
Durable storage to ensure no edits are lost
Retry and reconnect seamlessly restarts syncing
Conflict resolution algorithms automatically handle concurrent edits
“After a thorough evaluation of similar tools, we decided on Triplit as a key technology in a technically demanding client project and haven’t looked back since! Triplit has allowed us to move faster than ever when it comes to reliably syncing data between many users while keeping every interaction fast, even when users don’t have good connections. We are looking forward to using it in future projects.”
Code first schemas
Write your schemas in Typescript instead of config files or split across a dozen SQL files.
Automatic migrations generated from your edits
Type hinting in your editor
Data validation at runtime on client and server
schema.ts
import { Schema as S } from "@triplit/db";
export const schema = {
todos: {
schema: S.Schema({
completed: S.Boolean(),
created_at: S.String({
default: S.Default.now()
}),
id: S.String({
nullable: false,
default: S.Default.uuid()
}),
listId: S.String({ nullable: true }),
text: S.String(),
}),
},
};
schema.ts
import { Schema as S } from "@triplit/db";
export const schema = {
todos: {
schema: S.Schema({
completed: S.Boolean(),
created_at: S.String({
default: S.Default.now()
}),
id: S.String({
nullable: false,
default: S.Default.uuid()
}),
listId: S.String({ nullable: true }),
text: S.String(),
}),
},
};
“I've been using Triplit on my React native app for a while and it works great. Highly recommend. It's the only local-first database that hits these points for me: 1) Good and sane query language (not SQL). 2) Great typescript support. 3) Offline support. The cherry on top is that it's open-source and self-hostable.”
Complete data management
A full-featured database console for inspecting your data and schemas means you have all the control you'd expect from a production-ready database.
Triplit directly integrates with your UI framework
With first party support for React, and many more coming soon
With features rarely found in a traditional database
Relational, live, embedded, and open-source
What people are saying about Triplit