Triplit 1.0: The database that's in sync with your frontend
Triplit lets you build fast, reactive apps with an API that feels like working with local state. Triplit replaces all of your state, cache, and query management code... and maybe even your backend altogether.
The problem
Despite the growing demand for fast, reactive web apps, building them is still surprisingly painful. A large source of the pain stems from having to write plumbing code for your data across your entire stack: a query for your database, an object representation for your server, an API endpoint for your frontend to use, maybe even a server-side cache format with its own bespoke API. One small change to a database query often requires updating many files across multiple systems, potentially in different programming languages. If you want accurate static typing in your code—instead of having the dreaded any
type on every network response—then you'll be stuck relying on brittle code generation setups that you have to remember to run. And that's just the complexity of getting data from the backend to your frontend. Once the data is on the client, you'll be faced with an even more challenging task of maintaining the local cache to ensure it's accurate and up to date: a problem often regarded as one of the hardest in computer science. For as many apps that rely on either local caching or real-time syncing, it's maddening that we're still plagued by the same set of problems on every new project. It's time that we had a unified system that could solve these issues from end to end, fully spanning client and server.
Built for web developers
Triplit is a new database designed specifically for web and mobile developers. Unlike most database systems, Triplit goes beyond just storing data on a server — it's designed with the concerns of an application developer in mind. It's purpose built to ensure you no longer have to ask yourself: if I query data from a remote database, how should I cache that on the client? Or even more challenging, how can I keep the queried data up to date if the user modifies it locally, goes offline or if the data changes on the server?
The same query works on the server database and the client cache, and updates live.
// This is using our first party React hook bindings
const { results } = useQuery(Query('messages').Order('createdAt', 'DESC'));
With Triplit, queries are "live". You define the data you want and Triplit will handle fetching and caching the initial result and then syncing it for the lifetime of the component.
Typescript as a first-class citizen
As web developers, we wanted to use our lingua franca to work with our databases, so Triplit is built around Typescript. You can define your schema in Typescript, alongside your application code, and then benefit from:
- Type hinting as you write queries and mutations
- Fully-typed results based on your query, no matter how relational or complex
- Runtime validation of your data against your schema
- Support for storing data with JS-types like Sets, Dates, and nested Records
Both the server and client use the same schema definition so your data is type-safe and predictable without any code generation or build steps.
Designed to run anywhere your JavaScript runs
There's no shortage of environments to execute your Javascript code. Triplit is compatible with most JS runtimes including Cloudflare Workers, Browser, Node, Bun, Deno, and React Native (Hermes). But the interoperability doesn't stop there. Triplit is designed to work with any JS stack you want to use, including:
- First party framework bindings for React, Vue, Svelte, Angular, and SolidJS
- Flexible and pluggable storage including IndexedDB, SQLite, Expo SQLite, LMDB, and others
- Bring your own auth with any identify provider that supports JWTs. We have guides for Clerk and Supabase.
Super easy local development
Unlike many backend solutions that require installing a dozen tools or running a fleet of Docker containers to develop locally, Triplit just requires Node. All it takes is running npx triplit dev
to start a local server with your schema and data automatically applied. There's also a custom built interactive console to explore the data on your server like it was spreadsheet. Or if you'd rather, you can jump straight to Triplit Cloud to deploy your application without managing any servers yourself (you can start completely free!).
Fully Relational Capabilities powered by an advanced query planner
Triplit is a fully relational database. You can define relations ahead of time in your schema, or write arbitrary subqueries in a natural way.
Here's an example schema that serves as the single source of truth for both client and server:
const messagingSchema = S.Collections({
users: {
schema: S.Schema({
id: S.Id(),
name: S.String(),
friendIds: S.Set(S.String()),
}),
relations: {
// Define a relation for a user with an arbitrary query on another (or same!) collection
friends: S.RelationMany('users', {
where: [['id', 'in', '$1.friendIds']],
}),
},
},
});
And here's how easy it is to reference related data in your queries:
// Find all users who both have a username starting with "Alice"
// and also have a friend with a name starting with "Bob"
Query('users')
.Where('username', 'like' 'alice%')
.Where('friends.name', 'like', 'bob%') // <-- Filter on related data
.Include('friends') // <-- Include related data like GraphQL
Relational queries can get complex pretty quickly, so Triplit applies many of the same tricks and optimizations that popular SQL databases use to make sure your queries are fast and efficient while still allowing you to write queries naturally.
Bringing distributed systems algorithms to the client
Triplit itself is actually two databases: one that runs in the browser and one that runs on the server. These two databases are connected by a sync engine to keep results updated in real-time. This means you can write queries and mutations directly in your client code, with zero network latency.
Collaboration powered by CRDTs
Triplit's data model is defined as a CRDT (Conflict-free Replicated Data Types) to handle concurrent updates from multiple users. This means you can build collaborative applications that work predictably across devices and users even when users and their devices go offline. And unlike typical database setups, conflicts are minimized to individual attributes (columns) rather than entire entity (row/document)—this eliminates the most frustrating types of conflicts between concurrent editors.
Efficient query updates with incremental view maintenance
Under the hood, Triplit implements incremental view maintenance to update queries as new changes occur to the database. In your client code, you can keep your UI up-to-date without having to rerun the queries it relies on from scratch. On the server, this system calculates granular diffs to send to the client, rather than repeatedly sending the entire result set when one entity changes.
Cache invalidation handled automatically
Triplit's custom sync protocol allows the server to automatically evict data from a client cache when required, e.g. when data permissions change. This also works when a client goes offline and reconnects with a stale cache.
Safe, zero-downtime schema migrations
Triplit separates schema from data so you never accidentally lose data when modifying your schema. Additionally, Triplit will analyze your schema and detect any backwards incompatible changes that could cause downtime for connected clients. This means you can deploy schema changes with confidence that your users will never see a broken app.
Try Triplit Today
Leave behind the glue code and focus on the stuff that matters.
Join other builders in our Discord, star Triplit on Github, and/or just get started