| title | OffSync |
|---|---|
| description | Enable local-first applications with automatic data synchronization between edge devices and SQLite Cloud. |
| category | platform |
| status | publish |
| slug | offsync |
import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
import Callout from "@commons-components/Information/Callout.astro";
OffSync is a powerful SQLite Cloud feature that enables true local-first data synchronization for your applications. Powered by the SQLite Sync extension, it allows you to build robust, offline-capable applications where data is stored and processed on edge devices and seamlessly synchronized with a central SQLite Cloud database.
This architecture is ideal for mobile apps, IoT devices, and any application requiring high availability and low latency, even with intermittent network connectivity. By leveraging Conflict-free Replicated Data Types (CRDTs), OffSync ensures that changes made offline are merged automatically and without conflicts when the device reconnects.
OffSync extends standard SQLite tables with built-in support for offline work and automatic synchronization. This allows multiple devices to operate independently and then seamlessly merge their changes.
- Offline-First by Design: Applications work seamlessly even when devices are offline. Changes are queued locally and synced automatically when connectivity is restored.
- CRDT-Based Conflict Resolution: Merges updates deterministically and efficiently, ensuring eventual consistency across all replicas without complex merge logic.
- Seamless Integration: The sync layer is tightly integrated with SQLite Cloud, enabling secure data sharing across devices, users, and platforms.
When combined with Row-Level Security (RLS), OffSync allows you to build secure, multi-tenant applications where each user's data is safely isolated, both on the edge and in the cloud.
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard. The OffSync panel has four tabs: Sync Tables, Configuration, Devices, and Metrics.
When OffSync is not yet active for a database, the panel shows a brief explanation and an Enable OffSync button. Clicking it opens a confirmation dialog; after confirming, the database is registered with the sync service and the tabbed view appears.
To disable OffSync, click the Disable OffSync button in the top-right corner of the panel and confirm the action in the dialog that appears.
{/* */}
From the Sync Tables tab, select which tables in your database you want to keep synchronized. Once enabled, all changes to those tables will automatically sync with connected devices.
{/* VIDEO: dashboard_offsync_sync_tables.mp4 Show: Sync Tables tab open → toggle one or more tables on → confirmation that sync is active for those tables. */}
The Configuration tab contains two sub-sections:
Database ID — A read-only field showing the unique identifier for your OffSync-enabled database, with a copy button for convenience. Use this ID in your application to initialize the sync connection (see the sqlite-sync README for more details):
SELECT cloudsync_network_init('<database-id>');Push Notifications — Push notifications work out of the box. If you have enabled Expo enhanced security, provide your access token here. This is only required when using the sqlite-sync-react-native library with push mode enabled — the token adds an extra layer of security to prevent unauthorized push notifications.
{/* VIDEO: dashboard_offsync_configuration.mp4 Show: Configuration tab open → Database ID field with copy button clicked → scroll down to Push Notifications section → paste an Expo token → save → status changes to "Working". */}
In the Devices tab, you can view all devices currently connected to your database. Here you can check their sync status and remove devices if needed.
{/* VIDEO: dashboard_offsync_devices.mp4 Show: Devices tab open with a list of connected devices → inspect sync status of one device → remove a device from the list. */}
For OffSync to work correctly, the list of tables configured for synchronization—and their corresponding schemas—must be identical in both your local SQLite database and your SQLite Cloud database.The Metrics tab provides visibility into daily and cumulative usage for your OffSync-enabled database:
- Active devices — number of devices that have synced within the period
- Upload bytes — data sent from devices to SQLite Cloud
- Download bytes — data sent from SQLite Cloud to devices
{/* VIDEO: dashboard_offsync_metrics.mp4 Show: Metrics tab open → scroll through active devices chart → upload bytes chart → download bytes chart, ideally with some non-zero data visible. */}
Once enabled, any changes made to the selected tables via the SQLite Sync extension will be automatically synchronized with your SQLite Cloud database.