You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: client-sdk-references/javascript-web.mdx
+98-11Lines changed: 98 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -285,26 +285,113 @@ See [Usage Examples](/client-sdk-references/javascript-web/usage-examples) for f
285
285
286
286
## Developer Notes
287
287
288
-
### Connecting via WebSocket or HTTP Stream
288
+
### Connection Methods
289
289
290
-
This SDK connects to a PowerSync instance and streams sync commands via WebSockets (enabled by default since @powersync/web@1.6.0) or HTTP streaming.
290
+
This SDK supports two methods for streaming sync commands:
291
291
292
-
The WebSocket implementation uses reactive socket streams from the cross-platform [RSocket](https://github.com/powersync-ja/powersync-js/pull/rsocket.io) library. This allows the client to request commands from the server after processing existing events, alleviating any back-pressure build-up of commands. Sync commands are transmitted as BSON (binary) documents.
292
+
1. **WebSocket (Default)**
293
+
- The implementation leverages RSocket for handling reactive socket streams.
294
+
- Back-pressure is effectively managed through client-controlled command requests.
295
+
- Sync commands are transmitted efficiently as BSON (binary) documents.
296
+
- This method is **recommended** since it will support the future [BLOB column support](https://roadmap.powersync.com/c/88-support-for-blob-column-types) feature.
293
297
294
-
#### Benefits of using the WebSocket Method
298
+
2. **HTTP Streaming (Legacy)**
299
+
- This is the original implementation method.
300
+
- This method will not support the future BLOB column feature.
295
301
296
-
* BLOB column support will be added on top of the WebSocket implementation (the HTTP streaming method will not support this).
302
+
By default, the `PowerSyncDatabase.connect()` method uses WebSocket. You can optionally specify the `connectionMethod` to override this:
This SDK supports multiple Virtual File Systems (VFS), responsible for storing the local SQLite database:
315
+
316
+
#### 1. IDBBatchAtomicVFS (Default)
317
+
- This system utilizes IndexedDB as its underlying storage mechanism.
318
+
- Multiple tabs are fully supported across most modern browsers.
319
+
- Users may experience stability issues when using Safari.
299
320
300
-
The `PowerSyncDatabase` client's `connect` method supports a `connectionMethod` option. This is not required, as the WebSocket method is used by default.
321
+
#### 2. OPFS-based Alternatives
322
+
PowerSync supports two OPFS (Origin Private File System) implementations that generally offer improved performance:
323
+
324
+
##### OPFSCoopSyncVFS (Recommended)
325
+
- This implementation provides comprehensive multi-tab support across all major browsers.
326
+
- It offers the most reliable compatibility with Safari and Safari iOS.
| OPFSCoopSyncVFS | ✅ | ✅ | Recommended for multi-tab support |
358
+
| AccessHandlePoolVFS | ❌ | ❌ | Best for single-tab applications |
359
+
360
+
**Note**: There are known issues with OPFS when using Safari's incognito mode.
361
+
362
+
### Managing OPFS Storage
363
+
364
+
Unlike IndexedDB, OPFS storage cannot be managed through browser developer tools. The following utility functions can help you manage OPFS storage programmatically:
365
+
366
+
```js
367
+
// Clear all OPFS storage
368
+
asyncfunctionpurgeVFS() {
369
+
awaitpowerSync.disconnect();
370
+
awaitpowerSync.close();
371
+
372
+
constroot=awaitnavigator.storage.getDirectory();
373
+
awaitnewPromise(resolve=>setTimeout(resolve, 1)); // Allow .db-wal to become deletable
Copy file name to clipboardExpand all lines: client-sdk-references/react-native-and-expo.mdx
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -370,27 +370,27 @@ See [Usage Examples](/client-sdk-references/react-native-and-expo/usage-examples
370
370
371
371
## Developer Notes
372
372
373
-
### Connecting via WebSockets or HTTP Streams
373
+
### Connection Methods
374
374
375
-
This SDK connects to a PowerSync instance and streams sync commands via WebSockets (enabled by default since @powersync/react-native@1.11.0) or HTTP streams.
375
+
This SDK supports two methods for streaming sync commands:
376
376
377
-
The WebSocket implementation (available since version 1.4.6 of the SDK) uses reactive socket streams using the cross-platform [RSocket](https://github.com/powersync-ja/powersync-js/pull/rsocket.io) library. This allows the client to request commands from the server after processing existing events, alleviating any back-pressure build-up of commands. Sync commands are transmitted as BSON (binary) documents.
377
+
1. **WebSocket (Default)**
378
+
- The implementation leverages RSocket for handling reactive socket streams.
379
+
- Back-pressure is effectively managed through client-controlled command requests.
380
+
- Sync commands are transmitted efficiently as BSON (binary) documents.
381
+
- This method is **recommended** since it will support the future [BLOB column support](https://roadmap.powersync.com/c/88-support-for-blob-column-types) feature.
378
382
379
-
#### Benefits of using the WebSocket Method
383
+
2. **HTTP Streaming (Legacy)**
384
+
- This is the original implementation method.
385
+
- This method will not support the future BLOB column feature.
380
386
381
-
* BLOB column support will be added on top of the WebSocket implementation (the HTTP streaming method will not support this).
382
-
* If you are using Expo \<v51, then you no longer need to disable the [Flipper debug tools](/client-sdk-references/react-native-and-expo#android-flipper-network-plugin-for-http-streams) (this is required for HTTP streaming to work in debug Android builds).
383
-
* In internal testing, the WebSocket method was slightly faster than the HTTP streaming method on React Native.
384
-
385
-
#### Selecting Connection Method
386
-
387
-
The `PowerSyncDatabase` client's `connect` method supports a `connectionMethod` option. This is not required, as the WebSocket method is used by default.
387
+
By default, the `PowerSyncDatabase.connect()` method uses WebSocket. You can optionally specify the `connectionMethod` to override this:
0 commit comments