Skip to content

Commit fbfb9e3

Browse files
committed
Documentation edits made through Mintlify web editor
1 parent 13279cb commit fbfb9e3

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

client-sdk-references/javascript-web.mdx

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@ title: "JavaScript Web"
33
description: "Full SDK reference for using PowerSync in JavaScript Web clients"
44
sidebarTitle: Overview
55
---
6+
67
<CardGroup>
78
<Card title="PowerSync SDK on NPM" icon="npm" href="https://www.npmjs.com/package/@powersync/web">
8-
This SDK is distributed via NPM [[External link].](https://www.npmjs.com/package/@powersync/web)
9+
This SDK is distributed via NPM [\[External link\].](https://www.npmjs.com/package/@powersync/web)
910
</Card>
11+
1012
<Card title="Source Code" icon="github" href="https://github.com/powersync-ja/powersync-js/tree/main/packages/web">
11-
Refer to packages/web in the powersync-js repo on GitHub.
13+
Refer to packages/web in the powersync-js repo on GitHub.
1214
</Card>
15+
1316
<Card title="API Reference" icon="book" href="https://powersync-ja.github.io/powersync-js/web-sdk">
14-
Full API reference for the PowerSync SDK [[External link].](https://powersync-ja.github.io/powersync-js/web-sdk)
17+
Full API reference for the PowerSync SDK [\[External link\].](https://powersync-ja.github.io/powersync-js/web-sdk)
1518
</Card>
19+
1620
<Card title="Example Projects" icon="code" href="/resources/demo-apps-example-projects">
17-
Gallery of example projects/demo apps built with JavaScript Web stacks and PowerSync.
21+
Gallery of example projects/demo apps built with JavaScript Web stacks and PowerSync.
1822
</Card>
1923
</CardGroup>
2024

2125
### SDK Features
26+
2227
* Provides real-time streaming of database changes.
2328
* Offers direct access to the SQLite database, enabling the use of SQL on both client and server sides.
2429
* Operations are asynchronous by default, ensuring the user interface remains unblocked.
@@ -31,17 +36,17 @@ sidebarTitle: Overview
3136
See the [SDK's README](https://www.npmjs.com/package/@powersync/web) for installation instructions.
3237

3338
<Info>
34-
**Some peer dependencies are required.**
35-
36-
**Note**: As of @powersync/web@1.4.0, polyfills are bundled in the SDK and are no longer required.
39+
**Some peer dependencies are required.**
3740

38-
See the [Readme](https://www.npmjs.com/package/@powersync/web#installation) for the necessary peer dependencies that need to be installed.
41+
**Note**: As of @powersync/web@1.4.0, polyfills are bundled in the SDK and are no longer required.
3942

40-
By default this SDK connects to a PowerSync instance via WebSocket (from @powersync/web@1.6.0) or HTTP stream (before @powersync/web@1.6.0).
43+
See the [Readme](https://www.npmjs.com/package/@powersync/web#installation) for the necessary peer dependencies that need to be installed.
4144

42-
* See the [Developer Notes](/client-sdk-references/javascript-web#developer-notes) section below for details about connecting with either method.
45+
By default this SDK connects to a PowerSync instance via WebSocket (from @powersync/web@1.6.0) or HTTP stream (before @powersync/web@1.6.0).
4346

47+
* See the [Developer Notes](/client-sdk-references/javascript-web#developer-notes) section below for details about connecting with either method.
4448
</Info>
49+
4550
## Getting Started
4651

4752
Before implementing the PowerSync SDK in your project, make sure you have completed these steps:
@@ -50,29 +55,29 @@ Before implementing the PowerSync SDK in your project, make sure you have comple
5055
* [Configured your backend database](/installation/database-setup) and connected it to your PowerSync instance.
5156
* [Installed](/client-sdk-references/javascript-web#installation) the PowerSync Web SDK.
5257

53-
### 1\. Define the Schema
58+
### 1. Define the Schema
5459

5560
The first step is defining the schema for the local SQLite database.
5661

5762
This schema represents a "view" of the downloaded data. No migrations are required — the schema is applied directly when the local PowerSync database is constructed (as we'll show in the next step).
5863

5964
<Info>
60-
**Generate schema automatically**
65+
**Generate schema automatically**
6166

62-
In the [dashboard](/usage/tools/powersync-dashboard), the schema can be generated based off your sync rules by right-clicking on an instance and selecting **Generate client-side schema**.
67+
In the [dashboard](/usage/tools/powersync-dashboard), the schema can be generated based off your sync rules by right-clicking on an instance and selecting **Generate client-side schema**.
6368

64-
Similar functionality exists in the [CLI](/usage/tools/cli).
69+
Similar functionality exists in the [CLI](/usage/tools/cli).
6570
</Info>
6671

67-
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.
72+
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.
6873

6974
**Example**:
7075

7176
```js
7277
// AppSchema.ts
7378
import { column, Schema, Table } from '@powersync/web';
7479

75-
const lists = new TableV2({
80+
const lists = new Table({
7681
created_at: column.text,
7782
name: column.text,
7883
owner_id: column.text
@@ -108,7 +113,7 @@ export type ListRecord = Database['lists'];
108113
**Note**: No need to declare a primary key `id` column, as PowerSync will automatically create this.
109114
</Info>
110115

111-
### 2\. Instantiate the PowerSync Database
116+
### 2. Instantiate the PowerSync Database
112117

113118
Next, you need to instantiate the PowerSync database — this is the core managed database.
114119

@@ -134,9 +139,9 @@ export const db = new PowerSyncDatabase({
134139
```
135140

136141
<Note>
137-
**SDK versions lower than 1.2.0**
142+
**SDK versions lower than 1.2.0**
138143

139-
In SDK versions lower than 1.2.0, you will need to use the deprecated [WASQLitePowerSyncDatabaseOpenFactory](https://powersync-ja.github.io/powersync-js/web-sdk/classes/WASQLitePowerSyncDatabaseOpenFactory) syntax to instantiate the database.
144+
In SDK versions lower than 1.2.0, you will need to use the deprecated [WASQLitePowerSyncDatabaseOpenFactory](https://powersync-ja.github.io/powersync-js/web-sdk/classes/WASQLitePowerSyncDatabaseOpenFactory) syntax to instantiate the database.
140145
</Note>
141146

142147
Once you've instantiated your PowerSync database, you will need to call the [connect()](https://powersync-ja.github.io/powersync-js/web-sdk/classes/AbstractPowerSyncDatabase#connect) method to activate it.
@@ -149,7 +154,7 @@ export const setupPowerSync = async () => {
149154
};
150155
```
151156

152-
### 3\. Integrate with your Backend
157+
### 3. Integrate with your Backend
153158

154159
The PowerSync backend connector provides the connection between your application backend and the PowerSync client-slide managed SQLite database.
155160

@@ -160,9 +165,9 @@ It is used to:
160165

161166
Accordingly, the connector must implement two methods:
162167

163-
1. [PowerSyncBackendConnector.fetchCredentials](https://powersync-ja.github.io/powersync-js/web-sdk/interfaces/PowerSyncBackendConnector#fetchcredentials) \- 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.
164-
2. [PowerSyncBackendConnector.uploadData](https://powersync-ja.github.io/powersync-js/web-sdk/interfaces/PowerSyncBackendConnector#uploaddata) \- Use this to upload client-side changes to your app backend.
165-
\-> See [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for considerations on the app backend implementation.
168+
1. [PowerSyncBackendConnector.fetchCredentials](https://powersync-ja.github.io/powersync-js/web-sdk/interfaces/PowerSyncBackendConnector#fetchcredentials) - 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.
169+
2. [PowerSyncBackendConnector.uploadData](https://powersync-ja.github.io/powersync-js/web-sdk/interfaces/PowerSyncBackendConnector#uploaddata) - Use this to upload client-side changes to your app backend.
170+
-> See [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for considerations on the app backend implementation.
166171

167172
**Example**:
168173

@@ -203,10 +208,10 @@ Once the PowerSync instance is configured you can start using the SQLite DB func
203208
204209
The most commonly used CRUD functions to interact with your SQLite data are:
205210
206-
* [PowerSyncDatabase.get](/client-sdk-references/javascript-web#fetching-a-single-item) \- get (SELECT) a single row from a table.
207-
* [PowerSyncDatabase.getAll](/client-sdk-references/javascript-web#querying-items-powersync.getall) \- get (SELECT) a set of rows from a table.
208-
* [PowerSyncDatabase.watch](/client-sdk-references/javascript-web#watching-queries-powersync.watch) \- execute a read query every time source tables are modified.
209-
* [PowerSyncDatabase.execute](/client-sdk-references/javascript-web#mutations-powersync.execute) \- execute a write (INSERT/UPDATE/DELETE) query.
211+
* [PowerSyncDatabase.get](/client-sdk-references/javascript-web#fetching-a-single-item) - get (SELECT) a single row from a table.
212+
* [PowerSyncDatabase.getAll](/client-sdk-references/javascript-web#querying-items-powersync.getall) - get (SELECT) a set of rows from a table.
213+
* [PowerSyncDatabase.watch](/client-sdk-references/javascript-web#watching-queries-powersync.watch) - execute a read query every time source tables are modified.
214+
* [PowerSyncDatabase.execute](/client-sdk-references/javascript-web#mutations-powersync.execute) - execute a write (INSERT/UPDATE/DELETE) query.
210215
211216
### Fetching a Single Item
212217
@@ -308,4 +313,4 @@ See [JavaScript ORM Support](/client-sdk-references/javascript-web/javascript-or
308313
309314
## Troubleshooting
310315
311-
See [Troubleshooting](/resources/troubleshooting) for pointers to debug common issues.
316+
See [Troubleshooting](/resources/troubleshooting) for pointers to debug common issues.

0 commit comments

Comments
 (0)