Show HN: Syncular – 基于 TypeScript 和 Rust 核心的离线优先 SQL 同步工具
Show HN: Syncular – offline-first SQL sync with TypeScript and Rust cores

原始链接: https://github.com/syncular/syncular

Syncular 是一个服务器权威、优先支持离线使用的 SQL 同步引擎。它允许客户端维护一个本地 SQLite 数据库(在浏览器中使用 OPFS,在其他环境使用原生 SQLite),并通过乐观的写出箱(outbox)以及服务器端作为唯一事实来源的单一有序提交日志来处理写入操作。 核心功能与架构亮点包括: * **双核心实现**:TypeScript 和 Rust 核心通过一致性测试套件保持严格同步。 * **规范先行开发**:协议由规范性文档和黄金测试集定义;代码严格按照规范进行调整。 * **强大的测试**:采用严格的“无休眠(no-sleep)”原则、故障注入和内存环回测试,以确保可靠性。 * **全面的工具集**:包含原生 React Hooks、模式类型生成、端到端加密(E2EE)原语,并支持 Tauri、React Native 等主流平台及移动端框架。 * **开发体验**:针对快速部署进行了优化,集成了 Hono 和 Cloudflare Workers。 Syncular 对贡献保持高标准,强调对所有代码(包括 AI 生成的代码)进行严格的人工审查。

**Syncular** 是一个新的离线优先(offline-first)数据同步框架,它利用本地 SQLite 数据库提供了一种稳健的、以服务器为权威的数据同步架构。该项目由“quambo”开发,旨在解决离线优先开发中的复杂性问题,包括持久化写入、授权、冲突解决以及模式管理。 **主要技术特性:** * **混合方案:** 虽然标准的关联数据通过版本控制和冲突解决来处理,但用户也可以针对复杂的文档同步,按列选择启用 CRDT(无冲突复制数据类型)。 * **跨平台:** 核心部分采用 Rust 编写,并提供针对 TypeScript、Swift、Kotlin、Dart 和 Tauri 的绑定。 * **性能:** 开发人员声称,与 PowerSync 等现有替代方案相比,该框架的引导和重放速度显著更快。 **社区讨论:** 在 Hacker News 上,开发人员对该项目简化离线优先开发的愿景表示了兴趣,同时也对冲突解决的复杂性提出了质疑。一些用户对依赖基于行的 API 表示困惑,另一些用户则指出了浏览器存储清理以及在文档中使用大语言模型(LLM)所带来的挑战。开发者澄清称,Syncular 并非托管服务,而是一款旨在帮助开发者构建可靠、自托管离线优先应用的工具。
相关文章

原文

Animated syncular ASCII singularity

Server-authoritative, offline-first SQL sync you can operate. Clients keep a real local SQLite database (OPFS in the browser, native SQLite elsewhere), writes go through an optimistic outbox, and one ordered commit log on the server stays the source of truth.

Documentation · Quickstart · Live demos · Benchmarks · Blog

bun create syncular-app my-app
  • Spec-first: SPEC.md is normative and spec/vectors/ are golden fixtures; when spec and code disagree, the code changes. Two cores (TypeScript and Rust) are kept in lockstep by an implementation-agnostic conformance suite.
  • Test doctrine: loopback in-memory transport for integration scenarios; fault injection at the transport interface; tests wait on explicit readiness signals (sleeps are banned); real-socket tests few and quarantined. See packages/conformance.
  • One good path: the browser persists to OPFS and reports unsupported environments as errors; sync runs over the WebSocket.
Path What it is
packages/core Protocol codecs, shared types, vector round-trip
packages/server handleSyncRequest(bytes, ctx) + storage/auth interfaces (SQLite, Postgres, D1)
packages/server-hono, packages/server-workers Framework bindings (Hono, Cloudflare Workers)
packages/web-client @syncular/client: TS client core on @sqlite.org/sqlite-wasm
packages/react React hooks over the client
packages/typegen Schema IR + TypeScript emitter, named queries (cargo-free)
packages/crypto, packages/crdt-yjs Per-column E2EE primitives, Yjs CRDT mergers
packages/testing @syncular/testkit: in-memory loopback of real server + clients
packages/conformance Scenario runner both cores must pass
rust/ The Rust client core and its C-ABI FFI crate
bindings/ Tauri, React Native, Swift, Kotlin, Flutter
apps/docs The docs site (syncular.dev)
bun install
bun run check   # typecheck + lint + test

Read AGENTS.md first. The doctrine in it (spec-first, no fallbacks, no timers in tests, cross-core parity) applies to human and machine contributors alike.

On AI assistance: LLMs are welcome for tests, reproductions, benchmarks, docs, and production code. Review, understand, and iterate on everything you submit, and be ready to defend every line; production code gets the strictest review. In syncular's own development, LLM assistance is used mainly for writing tests and iterating over technical concepts, under that same review bar. Low-effort machine-generated PRs, issues, and comments are closed without comment. The full policy and the plain-text docs bundle for agents live at syncular.dev/llms.

联系我们 contact @ memedata.com