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
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.
18
22
</Card>
19
23
</CardGroup>
20
24
21
25
### SDK Features
26
+
22
27
* Provides real-time streaming of database changes.
23
28
* Offers direct access to the SQLite database, enabling the use of SQL on both client and server sides.
24
29
* Operations are asynchronous by default, ensuring the user interface remains unblocked.
@@ -31,17 +36,17 @@ sidebarTitle: Overview
31
36
See the [SDK's README](https://www.npmjs.com/package/@powersync/web) for installation instructions.
32
37
33
38
<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.**
37
40
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.
39
42
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.
41
44
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).
43
46
47
+
* See the [Developer Notes](/client-sdk-references/javascript-web#developer-notes) section below for details about connecting with either method.
44
48
</Info>
49
+
45
50
## Getting Started
46
51
47
52
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
50
55
*[Configured your backend database](/installation/database-setup) and connected it to your PowerSync instance.
51
56
*[Installed](/client-sdk-references/javascript-web#installation) the PowerSync Web SDK.
52
57
53
-
### 1\. Define the Schema
58
+
### 1. Define the Schema
54
59
55
60
The first step is defining the schema for the local SQLite database.
56
61
57
62
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).
58
63
59
64
<Info>
60
-
**Generate schema automatically**
65
+
**Generate schema automatically**
61
66
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**.
63
68
64
-
Similar functionality exists in the [CLI](/usage/tools/cli).
69
+
Similar functionality exists in the [CLI](/usage/tools/cli).
65
70
</Info>
66
71
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.
@@ -108,7 +113,7 @@ export type ListRecord = Database['lists'];
108
113
**Note**: No need to declare a primary key `id` column, as PowerSync will automatically create this.
109
114
</Info>
110
115
111
-
### 2\. Instantiate the PowerSync Database
116
+
### 2. Instantiate the PowerSync Database
112
117
113
118
Next, you need to instantiate the PowerSync database — this is the core managed database.
114
119
@@ -134,9 +139,9 @@ export const db = new PowerSyncDatabase({
134
139
```
135
140
136
141
<Note>
137
-
**SDK versions lower than 1.2.0**
142
+
**SDK versions lower than 1.2.0**
138
143
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.
140
145
</Note>
141
146
142
147
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.
The PowerSync backend connector provides the connection between your application backend and the PowerSync client-slide managed SQLite database.
155
160
@@ -160,9 +165,9 @@ It is used to:
160
165
161
166
Accordingly, the connector must implement two methods:
162
167
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.
166
171
167
172
**Example**:
168
173
@@ -203,10 +208,10 @@ Once the PowerSync instance is configured you can start using the SQLite DB func
203
208
204
209
The most commonly used CRUD functions to interact with your SQLite data are:
205
210
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.
210
215
211
216
### Fetching a Single Item
212
217
@@ -308,4 +313,4 @@ See [JavaScript ORM Support](/client-sdk-references/javascript-web/javascript-or
308
313
309
314
## Troubleshooting
310
315
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