A sync engine and database for building collaborative apps. Tandem is a work in progress and pre-1.0. APIs change without notice. Tandem gives each client a local, queryable database. Writes apply locally first. Tandem then syncs them to a server in the background and replays any pending local changes on top of what the server sends back. Features Optimistic local writes with rollback when the server rejects them Typed object queries with select, where, orderBy, limit, offset, and relations through with Live query subscriptions that re-run when matching data changes Server changes reach subscribed clients in one hop, before the pull that confirms them Optional IndexedDB persistence on the client, shared safely between browser tabs Scalar or compound tuple IDs, with typed prefix scans A server database that implements the sync protocol React bindings Packages Installation pnpm add @tanishqkancharla/tandem-core pnpm add @tanishqkancharla/tandem-react # React bindings pnpm add @tanishqkancharla/tandem-server # Server import { collection, defineSchema, t, TandemClient, } from "@tanishqkancharla/tandem-core" const schema = defineSchema({ todos: collection({ id: t.id(), text: t.string(), complete: t.boolean(), }), }) const client = new TandemClient({ schema }) await client.ready const tx = client.transact() tx.set("todos", { id: "1", text: "Try Tandem", complete: false }) await client.commit(tx) const { result, destroy } = client.subscribe( { collection: "todos", where: { complete: false } }, (todos) => console.log(todos), ) To sync between clients, pass a remote. See Quickstart. Documentation Visit tandemsync.dev or read the guides at docs.tandemsync.dev. Overview: what Tandem is and how the pieces fit together Quickstart: build a synced todo app Queries: query options and relations Server: run TandemServer and connect clients to it Agent chat: stream an agent's reply to every viewer with plain subscriptions How sync works: mutations, push, pull, and rebase Client: persistence, tab sharing, and lifecycle Mutations: named operations and transactions Storage adapters: PostgreSQL, MySQL, D1, and JSON file storage Application permissions and schema compatibility The full index is in docs/README.md. Examples examples/todo is a React todo app backed by a Hono server that runs TandemServer with JSON file storage. pnpm install pnpm exec turbo run dev --filter=@tandem/example-todo-web --filter=@tandem/example-todo-server Development This is a pnpm and Turborepo monorepo. pnpm install pnpm build pnpm test pnpm type-check pnpm lint pnpm format pnpm dst:run runs the deterministic simulation tests in dst. See specs/deterministic-simulation-testing.md.
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL
Show HN: Realtime sync engine without any new infra
Tandem is an open-source sync engine and client-side database that plugs into your existing infrastructure. Add the Tandem library to sync data in real time across your clients and server, without deploying any new services.I started work on Tandem 6 years ago as a side project. I was frustrated by the sync engine landscape at the time, thinking I could build a better DX and require less lock-in. Even now, sync engine companies and “full-stack databases” need you to migrate to their database or provision a separate service with auth, networking, etc. This makes them annoying to maintain and also harder to adopt incrementally.Tandem is designed to just be embedded into your existing frontend and backend code. You define a schema, set up a database adapter (any SQL-like database is supported), add the new sync endpoint to your existing API, and then you're good to go.Tandem uses DST (Deterministic Simulation Testing) on every PR and nightly to ensure correctness. Our DST system Gatekeeper lets us model not only storage and network failures, but also race conditions, by gating each call between client/server/other services independently.Tandem currently supports any React-based frontend, any serverful backend (like Cloudflare Durable Objects), and any SQL-like database. New adapters are easy to build, and PRs and issues are appreciated!Open-source and MIT licensed: https://github.com/tanishqkancharla/tandem Comments URL: https://news.ycombinator.com/item?id=50398763 Points: 1 # Comments: 0
번역 서비스가 일시 중지되어 원문을 표시합니다.