Skip to content

Commit 24871c6

Browse files
committed
docs: update readme
1 parent a1341fd commit 24871c6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Build real-time, collaborative mobile apps that work seamlessly offline and auto
4646
- **Optional (for push mode):**
4747
- [`expo-notifications`](https://docs.expo.dev/versions/latest/sdk/notifications/)
4848
- [`expo-constants`](https://docs.expo.dev/versions/latest/sdk/constants/)
49-
- Expo projects only
5049

5150
> **⚠️ Note:** This library is **native-only** (iOS/Android).
5251
@@ -817,13 +816,16 @@ return (
817816
Reactive queries **only fire on committed transactions**. When writing data, always use transactions:
818817
819818
```typescript
819+
const { execute } = useSqliteExecute();
820+
const { executeTransaction } = useSqliteTransaction();
821+
820822
// ✅ This will trigger reactive queries
821-
await db.transaction(async (tx) => {
822-
await tx.execute('INSERT INTO tasks (id, title) VALUES (?, ?);', [id, title]);
823+
await executeTransaction(async (tx) => {
824+
await tx.execute('INSERT INTO tasks (id, title) VALUES (?, ?)', [id, title]);
823825
});
824826

825827
// ❌ This will NOT trigger reactive queries
826-
await db.execute('INSERT INTO tasks (id, title) VALUES (?, ?);', [id, title]);
828+
await execute('INSERT INTO tasks (id, title) VALUES (?, ?)', [id, title]);
827829
```
828830

829831
The library automatically wraps sync operations in transactions, so reactive queries update when cloud changes arrive.
@@ -970,6 +972,8 @@ function TaskManager() {
970972

971973
**Important:** Direct `execute()` calls do NOT trigger reactive queries. To trigger reactive queries, use `useSqliteTransaction()` instead.
972974

975+
> **Note:** This hook automatically syncs changes to the cloud after each write, so your data is pushed immediately. If you use op-sqlite's `db.execute()` directly instead, changes will **not** be synced automatically — you would need to call `db.execute('SELECT cloudsync_network_send_changes()')` manually.
976+
973977
#### `useSqliteTransaction()`
974978

975979
Execute SQL commands within a transaction for atomic write operations.
@@ -1024,6 +1028,8 @@ function TaskManager() {
10241028

10251029
**Important:** Transactions automatically trigger reactive queries when they commit successfully. This is the recommended way to write data when using `useSqliteSyncQuery`.
10261030

1031+
> **Note:** This hook automatically syncs changes to the cloud after each transaction commits, so your data is pushed immediately. If you use op-sqlite's `db.transaction()` directly instead, changes will **not** be synced automatically — you would need to call `db.execute('SELECT cloudsync_network_send_changes()')` manually.
1032+
10271033
## 🚨 Error Handling
10281034

10291035
The library separates **fatal database errors** from **recoverable sync errors** to enable true offline-first operation.
@@ -1109,6 +1115,6 @@ Check out the [examples](./examples) directory for complete working examples:
11091115

11101116
## 🔗 Links
11111117

1112-
- [SQLite Sync Documentation](https://docs.sqlitecloud.io/docs/sqlite-sync) - Detailed sync docs with API references and best practices
1118+
- [SQLite Sync Documentation](https://docs.sqlitecloud.io/docs/sqlite-sync-introduction) - Detailed sync docs with API references and best practices
11131119
- [SQLite Cloud Dashboard](https://dashboard.sqlitecloud.io/) - Manage your databases
11141120
- [OP-SQLite API Reference](https://op-engineering.github.io/op-sqlite/docs/api)

0 commit comments

Comments
 (0)