Introducing Databases Anywhere with Turso Sync
Blog post from Turso
Turso Sync is a newly launched feature designed to enable seamless synchronization of local SQLite databases across various platforms, including Turso Cloud, enhancing the offline and online experience of modern applications. The sync package offers a similar API to the main @tursodatabase/database package but requires a remote database URL and authentication token, and it introduces push, pull, and checkpoint methods to manage synchronization and optimize local write-ahead logs (WAL). The feature includes advanced authentication capabilities with fine-grained token permissions and support for external authentication providers, currently limited to Clerk and Auth0. Conflict resolution is handled using a Last-Push-Wins strategy, with options for custom logic via a transform hook for more complex applications. The synchronization process utilizes logical mutations for local changes and physical page pulls for remote changes, maintaining the remote database as the source of truth. Turso Sync is expected to benefit front-end, machine learning, and backend applications, with future enhancements planned for partial sync, change data capture (CDC) optimizations, broader language support, and mobile integration.