Skip to content

Commit 45cca60

Browse files
benitavjoshua-journey-apps
authored andcommitted
Documentation edits made through Mintlify web editor
1 parent e00ee41 commit 45cca60

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

client-sdk-references/javascript-web.mdx

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
---
22
title: "JavaScript Web"
33
description: "Full SDK reference for using PowerSync in JavaScript Web clients"
4-
sidebarTitle: Overview
4+
sidebarTitle: "Overview"
55
---
66

77
import SdkFeatures from '/snippets/sdk-features.mdx';
88
import JavaScriptWebInstallation from '/snippets/javascript-web/installation.mdx';
99

10-
<CardGroup>
10+
<CardGroup cols={2}>
1111
<Card title="PowerSync SDK on NPM" icon="npm" href="https://www.npmjs.com/package/@powersync/web">
12-
This SDK is distributed via NPM [\[External link\].](https://www.npmjs.com/package/@powersync/web)
12+
This SDK is distributed via NPM [[External link].](https://www.npmjs.com/package/@powersync/web)
1313
</Card>
14-
1514
<Card title="Source Code" icon="github" href="https://github.com/powersync-ja/powersync-js/tree/main/packages/web">
1615
Refer to packages/web in the powersync-js repo on GitHub.
1716
</Card>
18-
1917
<Card title="API Reference" icon="book" href="https://powersync-ja.github.io/powersync-js/web-sdk">
20-
Full API reference for the PowerSync SDK [\[External link\].](https://powersync-ja.github.io/powersync-js/web-sdk)
18+
Full API reference for the PowerSync SDK [[External link].](https://powersync-ja.github.io/powersync-js/web-sdk)
2119
</Card>
22-
2320
<Card title="Example Projects" icon="code" href="/resources/demo-apps-example-projects">
2421
Gallery of example projects/demo apps built with JavaScript Web stacks and PowerSync.
2522
</Card>
@@ -37,9 +34,9 @@ import JavaScriptWebInstallation from '/snippets/javascript-web/installation.mdx
3734

3835
Before implementing the PowerSync SDK in your project, make sure you have completed these steps:
3936

40-
* Signed up for a PowerSync Cloud account ([here](https://accounts.journeyapps.com/portal/powersync-signup?s=docs)) or [self-host PowerSync](/self-hosting/getting-started).
41-
* [Configured your backend database](/installation/database-setup) and connected it to your PowerSync instance.
42-
* [Installed](/client-sdk-references/javascript-web#installation) the PowerSync Web SDK.
37+
- Signed up for a PowerSync Cloud account ([here](https://accounts.journeyapps.com/portal/powersync-signup?s=docs)) or [self-host PowerSync](/self-hosting/getting-started).
38+
- [Configured your backend database](/installation/database-setup) and connected it to your PowerSync instance.
39+
- [Installed](/client-sdk-references/javascript-web#installation) the PowerSync Web SDK.
4340

4441
### 1. Define the Schema
4542

@@ -55,7 +52,7 @@ This schema represents a "view" of the downloaded data. No migrations are requir
5552
Similar functionality exists in the [CLI](/usage/tools/cli).
5653
</Info>
5754

58-
The types available are `text`, `integer` and `real`. These should map directly to the values produced by the [Sync Rules](/usage/sync-rules). If a value doesn't match, it is cast automatically. For details on how Postgres types are mapped to the types below, see the section on [Types](/usage/sync-rules/types) in the *Sync Rules* documentation.
55+
The types available are `text`, `integer` and `real`. These should map directly to the values produced by the [Sync Rules](/usage/sync-rules). If a value doesn't match, it is cast automatically. For details on how Postgres types are mapped to the types below, see the section on [Types](/usage/sync-rules/types) in the _Sync Rules_ documentation.
5956

6057
**Example**:
6158

@@ -110,7 +107,7 @@ Its primary functions are to record all changes in the local database, whether o
110107
```js
111108
import { PowerSyncDatabase } from '@powersync/web';
112109
import { Connector } from './Connector';
113-
import { AppSchema } from './Schema';
110+
import { AppSchema } from './AppSchema';
114111

115112
export const db = new PowerSyncDatabase({
116113
// The schema you defined in the previous step
@@ -151,9 +148,9 @@ It is used to:
151148

152149
Accordingly, the connector must implement two methods:
153150

154-
1. [PowerSyncBackendConnector.fetchCredentials](https://github.com/powersync-ja/powersync-js/blob/ed5bb49b5a1dc579050304fab847feb8d09b45c7/packages/common/src/client/connection/PowerSyncBackendConnector.ts#L16) - This is called every couple of minutes and is used to obtain credentials for your app backend API. -> See [Authentication Setup](/installation/authentication-setup) for instructions on how the credentials should be generated.
151+
1. [PowerSyncBackendConnector.fetchCredentials](https://github.com/powersync-ja/powersync-js/blob/ed5bb49b5a1dc579050304fab847feb8d09b45c7/packages/common/src/client/connection/PowerSyncBackendConnector.ts#L16) - This is called every couple of minutes and is used to obtain credentials for your app backend API. -\> See [Authentication Setup](/installation/authentication-setup) for instructions on how the credentials should be generated.
155152
2. [PowerSyncBackendConnector.uploadData](https://github.com/powersync-ja/powersync-js/blob/ed5bb49b5a1dc579050304fab847feb8d09b45c7/packages/common/src/client/connection/PowerSyncBackendConnector.ts#L24) - Use this to upload client-side changes to your app backend.
156-
-> See [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for considerations on the app backend implementation.
153+
-\> See [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for considerations on the app backend implementation.
157154

158155
**Example**:
159156

@@ -189,10 +186,10 @@ Once the PowerSync instance is configured you can start using the SQLite DB func
189186

190187
The most commonly used CRUD functions to interact with your SQLite data are:
191188

192-
* [PowerSyncDatabase.get](/client-sdk-references/javascript-web#fetching-a-single-item) - get (SELECT) a single row from a table.
193-
* [PowerSyncDatabase.getAll](/client-sdk-references/javascript-web#querying-items-powersync.getall) - get (SELECT) a set of rows from a table.
194-
* [PowerSyncDatabase.watch](/client-sdk-references/javascript-web#watching-queries-powersync.watch) - execute a read query every time source tables are modified.
195-
* [PowerSyncDatabase.execute](/client-sdk-references/javascript-web#mutations-powersync.execute) - execute a write (INSERT/UPDATE/DELETE) query.
189+
- [PowerSyncDatabase.get](/client-sdk-references/javascript-web#fetching-a-single-item) - get (SELECT) a single row from a table.
190+
- [PowerSyncDatabase.getAll](/client-sdk-references/javascript-web#querying-items-powersync.getall) - get (SELECT) a set of rows from a table.
191+
- [PowerSyncDatabase.watch](/client-sdk-references/javascript-web#watching-queries-powersync.watch) - execute a read query every time source tables are modified.
192+
- [PowerSyncDatabase.execute](/client-sdk-references/javascript-web#mutations-powersync.execute) - execute a write (INSERT/UPDATE/DELETE) query.
196193

197194
### Fetching a Single Item
198195

@@ -259,6 +256,7 @@ const deleteList = async (id) => {
259256
});
260257
};
261258
```
259+
262260
## Configure Logging
263261

264262
```js
@@ -299,7 +297,6 @@ This SDK supports two methods for streaming sync commands:
299297
- Back-pressure is effectively managed through client-controlled command requests.
300298
- Sync commands are transmitted efficiently as BSON (binary) documents.
301299
- 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.
302-
303300
2. **HTTP Streaming (Legacy)**
304301
- This is the original implementation method.
305302
- This method will not support the future BLOB column feature.
@@ -319,14 +316,17 @@ powerSync.connect(connector, { connectionMethod: SyncStreamConnectionMethod.HTTP
319316
This SDK supports multiple Virtual File Systems (VFS), responsible for storing the local SQLite database:
320317

321318
#### 1. IDBBatchAtomicVFS (Default)
319+
322320
- This system utilizes IndexedDB as its underlying storage mechanism.
323321
- Multiple tabs are fully supported across most modern browsers.
324322
- Users may experience stability issues when using Safari.
325323

326324
#### 2. OPFS-based Alternatives
325+
327326
PowerSync supports two OPFS (Origin Private File System) implementations that generally offer improved performance:
328327

329328
##### OPFSCoopSyncVFS (Recommended)
329+
330330
- This implementation provides comprehensive multi-tab support across all major browsers.
331331
- It offers the most reliable compatibility with Safari and Safari iOS.
332332
- Example configuration:
@@ -350,17 +350,18 @@ export const db = new PowerSyncDatabase({
350350
```
351351

352352
##### AccessHandlePoolVFS
353+
353354
- This implementation delivers optimal performance for single-tab applications.
354355
- The system is not designed to handle multiple tab scenarios.
355356
- The configuration is similar to `OPFSCoopSyncVFS`, but requires using `WASQLiteVFS.AccessHandlePoolVFS`.
356357

357358
#### VFS Compatibility Matrix
358359

359-
| VFS Type | Multi-Tab Support (Standard Browsers) | Multi-Tab Support (Safari/iOS) | Notes |
360-
|----------|---------------------------|---------------------|--------|
361-
| IDBBatchAtomicVFS ||| Default, some Safari stability issues |
362-
| OPFSCoopSyncVFS ||| Recommended for multi-tab support |
363-
| AccessHandlePoolVFS ||| Best for single-tab applications |
360+
| VFS Type | Multi-Tab Support (Standard Browsers) | Multi-Tab Support (Safari/iOS) | Notes |
361+
| ------------------- | ------------------------------------- | ------------------------------ | ------------------------------------- |
362+
| IDBBatchAtomicVFS | | | Default, some Safari stability issues |
363+
| OPFSCoopSyncVFS | | | Recommended for multi-tab support |
364+
| AccessHandlePoolVFS | | | Best for single-tab applications |
364365

365366
**Note**: There are known issues with OPFS when using Safari's incognito mode.
366367

@@ -405,4 +406,4 @@ See [JavaScript ORM Support](/client-sdk-references/javascript-web/javascript-or
405406

406407
## Troubleshooting
407408

408-
See [Troubleshooting](/resources/troubleshooting) for pointers to debug common issues.
409+
See [Troubleshooting](/resources/troubleshooting) for pointers to debug common issues.

0 commit comments

Comments
 (0)