Skip to content

Commit 690a1c8

Browse files
committed
docs: update OffSync configuration details and enhance tab descriptions
1 parent be89cdd commit 690a1c8

File tree

1 file changed

+125
-27
lines changed

1 file changed

+125
-27
lines changed

sqlite-cloud/platform/offsync.mdx

Lines changed: 125 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,159 @@ When combined with [Row-Level Security (RLS)](/docs/rls), OffSync allows you to
3232

3333
## Configuring OffSync
3434

35-
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
36-
The OffSync panel has four tabs: **Sync Tables**, **Configuration**, **Devices**, and **Metrics**.
35+
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard. Select a database from the left panel — the list shows all databases in your project along with their OffSync status. The right panel has four tabs: **Database Setup**, **Client Integration**, **Devices**, and **Metrics**.
3736

3837
### Enabling and Disabling OffSync
3938

40-
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.
39+
When OffSync is not yet active for a database, the right 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.
4140

42-
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.
41+
To disable OffSync, click the **Disable OffSync** button in the top-right corner of the panel and confirm in the dialog that appears.
4342

4443
{/* <VideoPlayer src={enableDisableSync} /> */}
4544

46-
### Enable Tables for Synchronization
45+
---
46+
47+
## Database Setup Tab
48+
49+
The **Database Setup** tab handles the **server-side configuration** of OffSync. This is where you verify the database connection and choose which tables to synchronize.
50+
51+
### Connection Status
52+
53+
A connection card at the top of the tab shows whether the sync service can reach your database. When healthy, it displays the **Host**, **Port**, and **Database** name alongside a green **Connected** indicator.
54+
55+
If the connection cannot be established, a warning appears with an action button to resolve it:
56+
57+
- On **Supabase self-hosted / PostgreSQL** workspaces, click **Configure Connection** to provide the correct connection credentials via the connection settings sheet. The card also shows an **Edit** button when the connection is healthy, so you can update the credentials at any time.
58+
- On **SQLite Cloud** workspaces, click **Restore Connection** to automatically regenerate the internal API key used by the sync service.
59+
60+
If the OffSync extension is not detected on the database, a warning is shown with a link to the installation documentation.
61+
62+
### Select Tables to Enable OffSync
63+
64+
Below the connection card, you can choose which tables to synchronize. This section is only shown when the connection is healthy. A counter shows how many tables are currently selected (e.g., *1 of 1 selected*).
65+
66+
- Use the **Filter tables** input to search through large table lists.
67+
- Check or uncheck individual tables to include or exclude them from synchronization. Tables already registered with the sync service are marked as **Enabled**.
68+
- Use **Select All** / **Deselect All** to manage the full list at once.
69+
70+
Once you have made your selection, click **Deploy Changes** (bottom-right of the panel) to apply. From that point on, any writes to those tables via the SQLite Sync extension will be automatically synchronized.
71+
72+
<Callout type="note" title="Matching Schemas and Tables">
73+
For OffSync to work correctly, the tables you enable for synchronization—and their schemas—must be identical in both your local SQLite database and your SQLite Cloud database.
74+
</Callout>
4775

48-
From the **Sync Tables** tab, select which tables in your database you want to keep synchronized.
49-
Once enabled, all changes to those tables will automatically sync with connected devices.
76+
{/* VIDEO: dashboard_offsync_database_setup.mp4
77+
Show: Database Setup tab → Connected indicator → select/deselect tables → Deploy Changes. */}
5078

51-
{/* VIDEO: dashboard_offsync_sync_tables.mp4
52-
Show: Sync Tables tab open → toggle one or more tables on → confirmation that sync is active for those tables. */}
79+
---
80+
81+
## Client Integration Tab
5382

54-
### Configuration Tab
83+
The **Client Integration** tab contains everything you need to **connect your local application** to the cloud database. This includes your Database ID, how authentication works, and how to handle push notifications.
84+
85+
<Callout type="note" title="Workspace-specific instructions">
86+
The options available in this tab depend on your workspace type. **SQLite Cloud** workspaces use API keys or access tokens. **Supabase self-hosted and PostgreSQL** workspaces use database credentials or JWT-based authentication. The relevant options are displayed automatically based on your project.
87+
</Callout>
5588

56-
The **Configuration** tab contains two sub-sections:
89+
### Database ID
5790

58-
**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 <a href="https://github.com/sqliteai/sqlite-sync" target="_blank">sqlite-sync README</a> for more details):
91+
A unique identifier for your OffSync-enabled database. Pass this ID to the <a href="https://github.com/sqliteai/sqlite-sync" target="_blank">SQLite Sync</a> extension in your client application to initialize the sync connection:
5992

6093
```sql
6194
SELECT cloudsync_network_init('<database-id>');
6295
```
6396

64-
**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.
97+
Use the **Copy** button to copy the ID to your clipboard.
98+
99+
### Row Level Security (RLS)
100+
101+
RLS controls which data each user can access. Instead of giving clients full access to the database, it ensures each user can only read or modify their own data. Choose one of two modes:
102+
103+
- **No, bypass RLS** — Best for trusted environments such as internal tools or server-side clients. The client has full access to all synced tables.
104+
- **Yes, enforce RLS** — Best for user-facing apps. Each sync request is tied to a user identity, and access rules are applied automatically.
105+
106+
Your selection here determines how the **Authentication** section below is configured.
65107

66-
{/* VIDEO: dashboard_offsync_configuration.mp4
67-
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". */}
108+
### Authentication
68109

69-
### Manage Connected Devices
110+
The authentication method shown depends on your **workspace type** and **RLS mode** selection.
111+
112+
**SQLite Cloud workspaces — RLS bypassed (API Key)**
113+
114+
Select a **User** and the corresponding **API Key** from the dropdowns. The code snippet below updates automatically:
115+
116+
```sql
117+
-- 1. Connect to your database
118+
SELECT cloudsync_network_init('<database-id>');
119+
120+
-- 2. Authenticate using API key (full access, no RLS)
121+
SELECT cloudsync_network_set_apikey('<your-api-key>');
122+
```
70123

71-
In the **Devices** tab, you can view all devices currently connected to your database.
72-
Here you can check their sync status and remove devices if needed.
124+
**SQLite Cloud workspaces — RLS enforced (Access Token)**
125+
126+
Authentication is done via a user-scoped access token. Two action cards guide you through the setup:
127+
128+
- **Configure RLS** — Links to the RLS page to define which rows each user can access.
129+
- **Generate user access tokens** — Links to the Weblite API to generate an access token per user.
130+
131+
Once you have a token, pass it to your client:
132+
133+
```sql
134+
-- 1. Connect to your database
135+
SELECT cloudsync_network_init('<database-id>');
136+
137+
-- 2. Authenticate as a specific user (RLS enforced)
138+
SELECT cloudsync_network_set_token('<user-access-token>');
139+
```
140+
141+
**Supabase self-hosted / PostgreSQL workspaces — RLS bypassed (Username & Password)**
142+
143+
Connects using your database credentials, giving full access to all synced tables and bypassing Row Level Security. Refer to the quickstart guide shown at the top of the tab for provider-specific instructions.
144+
145+
**Supabase self-hosted / PostgreSQL workspaces — RLS enforced (JWT)**
146+
147+
To verify users and apply access rules, you must configure a JWT authentication provider. A status card shows the current configuration:
148+
149+
- **Not configured** — Users cannot be verified. Click **Configure authentication** to set up your provider.
150+
- **Configured** — Shows the active method (HMAC Secret HS256 or JWKS Issuer Validation). Click **Edit** to update it.
151+
152+
Refer to the quickstart guide shown at the top of the tab for provider-specific integration instructions.
153+
154+
### Push Notifications
155+
156+
Real-time push notifications are active out of the box when using the <a href="https://github.com/sqliteai/sqlite-sync-react-native" target="_blank">sqlite-sync-react-native</a> library with push mode enabled.
157+
158+
A status card shows the current **Expo Security** configuration:
159+
160+
- **Not configured** — Standard push notifications are active with no extra security.
161+
- **Configured** — An Expo access token has been provided, adding an extra security layer to prevent unauthorized push notifications. The date the token was last updated is also shown.
162+
163+
Use **Configure** to add a token, **Edit** to update an existing one, or **Delete** to remove it.
164+
165+
{/* VIDEO: dashboard_offsync_client_integration.mp4
166+
Show: Client Integration tab → Database ID copy → RLS toggle → auth section changes → code snippet → Push Notifications configure. */}
167+
168+
---
169+
170+
## Devices Tab
171+
172+
The **Devices** tab lists all devices currently synchronized with the selected database. For each device you can see its **Site ID** and the timestamp of its **Last Sync**. Use the **Remove** button to deregister a device.
73173

74174
{/* VIDEO: dashboard_offsync_devices.mp4
75-
Show: Devices tab open with a list of connected devices → inspect sync status of one device → remove a device from the list. */}
175+
Show: Devices tab list of connected devices → remove a device. */}
76176

77-
<Callout type="note" title="Matching Schemas and Tables">
78-
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.
79-
</Callout>
177+
---
80178

81-
### Metrics Tab
179+
## Metrics Tab
82180

83-
The **Metrics** tab provides visibility into daily and cumulative usage for your OffSync-enabled database:
181+
The **Metrics** tab provides visibility into usage for your OffSync-enabled database over time:
84182

85183
- **Active devices** — number of devices that have synced within the period
86184
- **Upload bytes** — data sent from devices to SQLite Cloud
87185
- **Download bytes** — data sent from SQLite Cloud to devices
88186

89-
{/* VIDEO: dashboard_offsync_metrics.mp4
90-
Show: Metrics tab open → scroll through active devices chart → upload bytes chart → download bytes chart, ideally with some non-zero data visible. */}
187+
The usage summary at the top of the left panel shows the total data transferred for the current billing period.
91188

92-
Once enabled, any changes made to the selected tables via the SQLite Sync extension will be automatically synchronized with your SQLite Cloud database.
189+
{/* VIDEO: dashboard_offsync_metrics.mp4
190+
Show: Metrics tab → active devices chart → upload bytes chart → download bytes chart. */}

0 commit comments

Comments
 (0)