{"id":31532279,"url":"https://github.com/sqliteai/sqlite-sync","last_synced_at":"2026-04-02T12:03:53.075Z","repository":{"id":305885293,"uuid":"982638943","full_name":"sqliteai/sqlite-sync","owner":"sqliteai","description":"CRDT-based offline-first sync for SQLite. Syncs automatically with SQLite Cloud, PostgreSQL, and Supabase. No conflicts, no data loss, no backend to build. For offline-first apps and AI agents.","archived":false,"fork":false,"pushed_at":"2026-03-25T22:10:25.000Z","size":3776,"stargazers_count":432,"open_issues_count":0,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-03-26T18:40:12.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sqlite.ai","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqliteai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-13T07:32:24.000Z","updated_at":"2026-03-26T11:24:42.000Z","dependencies_parsed_at":"2025-07-22T14:42:31.684Z","dependency_job_id":"3e2b1668-fc45-41f8-8f40-af01c7c83ff6","html_url":"https://github.com/sqliteai/sqlite-sync","commit_stats":null,"previous_names":["sqliteai/sqlite-sync"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/sqliteai/sqlite-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fsqlite-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fsqlite-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fsqlite-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fsqlite-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqliteai","download_url":"https://codeload.github.com/sqliteai/sqlite-sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqliteai%2Fsqlite-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31305971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T09:48:21.550Z","status":"ssl_error","status_checked_at":"2026-04-02T09:48:19.196Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-04T03:01:44.938Z","updated_at":"2026-04-02T12:03:53.063Z","avatar_url":"https://github.com/sqliteai.png","language":"C","readme":"# SQLite Sync\n\n[![sqlite-sync coverage](https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fsqliteai.github.io%2Fsqlite-sync%2F\u0026search=Functions%3A%3C%5C%2Ftd%3E%5Cs*%3Ctd%20class%3D%22headerCovTableEntry(?:Hi|Med|Lo)%22%3E(%5B%5Cd.%5D%2B)%26nbsp%3B%25\u0026replace=%241%25\u0026label=coverage\u0026labelColor=rgb(85%2C%2085%2C%2085)%3B\u0026color=rgb(167%2C%20252%2C%20157)%3B\u0026link=https%3A%2F%2Fsqliteai.github.io%2Fsqlite-sync%2F)](https://sqliteai.github.io/sqlite-sync/)\n\n**SQLite Sync** is a multi-platform extension that turns any SQLite database into a **conflict-free, offline-first replica** that syncs automatically with **[SQLite Cloud](https://sqlitecloud.io/)** nodes, **PostgreSQL** servers, and **Supabase** instances. One function call is all it takes: no backend to build, no sync protocol to implement.\n\nBuilt on **CRDT** (Conflict-free Replicated Data Types), it guarantees:\n\n- **No data loss.** Devices update independently, even offline, and all changes merge automatically.\n- **No conflicts.** Deterministic merge, no manual conflict resolution, ever.\n- **No extra infrastructure.** A globally distributed network of **CloudSync microservices** handles routing, packaging, and delivery of changes between SQLite and other DBMS nodes.\n\n## Why SQLite Sync?\n\n**For offline-first apps** (mobile, desktop, IoT, edge): devices work with a local SQLite database and sync when connectivity is available. Changes queue locally and merge seamlessly on reconnect.\n\n**For AI agents**: agents that maintain memory, notes, or shared state in SQLite can sync across instances without coordination. **[Block-Level LWW](#block-level-lww)** was specifically designed to keep **markdown files** in sync: multiple agents editing different sections of the same document preserve all changes after sync.\n\n## What Can You Build with SQLite Sync?\n\n### Offline-First Apps\n- **Shared To-Do Lists**: users independently update tasks and sync effortlessly.\n- **Note-Taking Apps**: real-time collaboration with offline editing.\n- **Field Data Collection**: for remote inspections, agriculture, or surveys.\n- **Point-of-Sale Systems**: offline-first retail solutions with synced inventory.\n\n### AI Agent Sync\n- **Agent Memory**: multiple agents share and update a common SQLite database, syncing state across instances without coordination.\n- **Markdown Knowledge Bases**: agents independently edit different sections of shared markdown documents, with Block-Level LWW preserving all changes.\n- **Distributed Pipelines**: agents running on different nodes accumulate results locally and merge them into a single consistent dataset.\n\n### Enterprise and Multi-Tenant\n- **CRM Systems**: sync leads and clients per user with row-level access control.\n- **SaaS Platforms**: row-level access for each user or team using a single shared database.\n- **Project Management Tools**: offline-friendly planning and task management.\n\n### Personal Apps\n- **Journaling and Diaries**: private entries that sync across devices.\n- **Habit Trackers**: sync progress with data security and consistency.\n- **Bookmarks and Reading Lists**: personal or collaborative content management.\n\n## Key Features\n\n| Feature | Description |\n|---------|-------------|\n| **CRDT-based sync** | Causal-Length Set, Delete-Wins, Add-Wins, and Grow-Only Set algorithms |\n| **Block-Level LWW** | Line-level merge for text/markdown columns, concurrent edits to different lines are preserved |\n| **Built-in networking** | Embedded network layer (libcurl or native), single function call to sync |\n| **Row-Level Security** | Server-enforced RLS: each client syncs only the rows it is authorized to see |\n| **Multi-platform** | Linux, macOS, Windows, iOS, Android, WASM |\n\n## Quick Start\n\n### 1. Install\n\nDownload a pre-built binary from the [Releases](https://github.com/sqliteai/sqlite-sync/releases) page, or install a platform package (see [full installation guide](./docs/installation.md) for platform-specific code examples):\n\n| Platform | Install |\n|----------|---------|\n| **SQLite CLI / C** | `.load ./cloudsync` or `SELECT load_extension('./cloudsync');` |\n| **Swift** | [Add this repo as a Swift Package dependency](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app), follow [steps 4 and 5](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/platforms/ios.md#4-set-up-sqlite-with-extension-loading), and load extension with `CloudSync.path`  |\n| **Android** | `implementation 'ai.sqlite:sync:1.0.0'` ([Maven Central](https://central.sonatype.com/artifact/ai.sqlite/sync)) |\n| **Flutter** | `flutter pub add sqlite_sync` ([pub.dev](https://pub.dev/packages/sqlite_sync)) |\n| **Expo** | `npm install @sqliteai/sqlite-sync-expo` |\n| **React Native** | `npm install @sqliteai/sqlite-sync-react-native` |\n| **WASM** | `npm install @sqliteai/sqlite-wasm` ([npm](https://www.npmjs.com/package/@sqliteai/sqlite-wasm)) |\n\n### 2. Create a table and enable sync\n\n```sql\n.load ./cloudsync\n\nCREATE TABLE tasks (\n    id TEXT PRIMARY KEY,\n    title TEXT NOT NULL DEFAULT '',\n    done INTEGER NOT NULL DEFAULT 0\n);\n\n-- Enable CRDT sync on the table\nSELECT cloudsync_init('tasks');\n```\n\n### 3. Use your database normally\n\n```sql\nINSERT INTO tasks (id, title) VALUES (cloudsync_uuid(), 'Buy groceries');\nINSERT INTO tasks (id, title) VALUES (cloudsync_uuid(), 'Review PR #42');\n\nUPDATE tasks SET done = 1 WHERE title = 'Buy groceries';\n\nSELECT * FROM tasks;\n```\n\n### 4. Sync with the cloud\n\n```sql\n-- Connect to your SQLite Cloud managed database\n-- (get the managed database ID from the OffSync page on the SQLite Cloud dashboard)\nSELECT cloudsync_network_init('your-managed-database-id');\nSELECT cloudsync_network_set_apikey('your-api-key');\n\n-- Send local changes and receive remote changes\nSELECT cloudsync_network_sync();\n-- Returns JSON: {\"send\":{\"status\":\"synced\",\"localVersion\":3,\"serverVersion\":3},\"receive\":{\"rows\":0,\"tables\":[]}}\n\n-- Call periodically to stay in sync\nSELECT cloudsync_network_sync();\n\n-- Before closing the connection\nSELECT cloudsync_terminate();\n```\n\n### 5. Sync from another device\n\nOn a second device (or a second database for testing), repeat the same setup:\n\n```sql\n-- Device B: load extension, create the same table, init sync\n.load ./cloudsync\n\nCREATE TABLE tasks (\n    id TEXT PRIMARY KEY,\n    title TEXT NOT NULL DEFAULT '',\n    done INTEGER NOT NULL DEFAULT 0\n);\n\nSELECT cloudsync_init('tasks');\n\n-- Connect to the same cloud database\nSELECT cloudsync_network_init('your-managed-database-id');\nSELECT cloudsync_network_set_apikey('your-api-key');\n\n-- Pull changes from Device A\nSELECT cloudsync_network_sync();\n-- Call again: the first call triggers package preparation, the second downloads it\nSELECT cloudsync_network_sync();\n\n-- Device A's tasks are now here\nSELECT * FROM tasks;\n\n-- Add data from this device\nINSERT INTO tasks (id, title) VALUES (cloudsync_uuid(), 'Call the dentist');\n\n-- Send this device's changes to the cloud\nSELECT cloudsync_network_sync();\n\n-- Before closing the connection\nSELECT cloudsync_terminate();\n```\n\nBack on Device A, calling `cloudsync_network_sync()` will pull Device B's changes. The CRDT engine ensures all devices converge to the same data, automatically, with no conflicts.\n\n## Block-Level LWW\n\nStandard CRDT sync replaces an entire cell when two devices edit the same column. **Block-Level LWW** splits text into lines and merges them independently, designed for keeping **markdown files and agent memory** in sync.\n\n```sql\nCREATE TABLE notes (\n    id TEXT PRIMARY KEY NOT NULL,\n    title TEXT NOT NULL DEFAULT '',\n    body TEXT NOT NULL DEFAULT ''\n);\n\nSELECT cloudsync_init('notes');\nSELECT cloudsync_set_column('notes', 'body', 'algo', 'block');\n```\n\nNow two agents (or devices) can edit different lines of the same note, and both edits are preserved after sync. See the full guide: **[Block-Level LWW Documentation](./docs/block-lww.md)**.\n\n## Row-Level Security\n\nWith SQLite Cloud's RLS, a single shared cloud database serves all users while each client only sees and syncs its own rows. Policies are enforced server-side: a compromised client cannot bypass access controls.\n\n- One database, multiple tenants, no per-user database provisioning.\n- Each client syncs only authorized rows, minimal bandwidth and storage.\n\nSee the full guide: **[Row-Level Security Documentation](./docs/row-level-security.md)**.\n\n## Documentation\n\n- **[API Reference](./API.md)**: all functions, parameters, and examples\n- **[Installation Guide](./docs/installation.md)**: platform-specific setup (Swift, Android, Expo, React Native, Flutter, WASM)\n- **[Block-Level LWW Guide](./docs/block-lww.md)**: line-level text merge for markdown and documents\n- **[Row-Level Security Guide](./docs/row-level-security.md)**: multi-tenant access control with server-enforced policies\n- **[Database Schema Recommendations](./docs/schema.md)**: primary keys, constraints, foreign keys, triggers\n- **[Custom Network Layer](./docs/internal/network.md)**: replace the built-in libcurl networking\n- **[Examples](./examples/)**: complete walkthroughs (todo app, sport tracker, Swift multiplatform)\n\n## SQLite Cloud Setup\n\n1. Sign up at [SQLite Cloud](https://sqlitecloud.io/) and create a project.\n2. Create a database and your tables in the [dashboard](https://dashboard.sqlitecloud.io/).\n3. Enable synchronization: click **\"OffSync\"** for your database and select the tables to sync.\n4. Copy the managed database ID and API key from the dashboard.\n5. Use `cloudsync_network_init()` and `cloudsync_network_set_apikey()` locally, then call `cloudsync_network_sync()`.\n\nFor token-based authentication (required for RLS), use `cloudsync_network_set_token()` instead of `cloudsync_network_set_apikey()`.\n\n## Integrations\n\nPart of the **[SQLite AI](https://sqlite.ai)** ecosystem:\n\n| Extension | Description |\n|-----------|-------------|\n| **[SQLite-AI](https://github.com/sqliteai/sqlite-ai)** | On-device inference and embedding generation |\n| **[SQLite-Memory](https://github.com/sqliteai/sqlite-memory)** | Markdown-based AI agent memory with semantic search |\n| **[SQLite-Vector](https://github.com/sqliteai/sqlite-vector)** | Vector search for embeddings stored as BLOBs |\n| **[SQLite-Agent](https://github.com/sqliteai/sqlite-agent)** | Run autonomous AI agents from within SQLite |\n| **[SQLite-MCP](https://github.com/sqliteai/sqlite-mcp)** | Connect SQLite databases to MCP servers |\n| **[SQLite-JS](https://github.com/sqliteai/sqlite-js)** | Custom SQLite functions in JavaScript |\n| **[Liteparser](https://github.com/sqliteai/liteparser)** | Fully compliant SQLite SQL parser |\n\n## License\n\nThis project is licensed under the [Elastic License 2.0](./LICENSE.md). For production or managed service use, [contact SQLite Cloud, Inc](mailto:info@sqlitecloud.io) for a commercial license.\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqliteai%2Fsqlite-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqliteai%2Fsqlite-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqliteai%2Fsqlite-sync/lists"}