Skip to content

Commit bdee9cc

Browse files
authored
Add testing instructions to Readme
1 parent 5c3947f commit bdee9cc

File tree

1 file changed

+72
-50
lines changed

1 file changed

+72
-50
lines changed

packages/powersync/README.md

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,73 @@
11
# PowerSync SDK for Dart/Flutter
22

3-
[PowerSync](https://powersync.co) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases.
3+
[PowerSync](https://powersync.com) is a service and set of SDKs that keeps PostgreSQL databases in sync with on-device SQLite databases.
4+
5+
## *** Web support - Open alpha ***
6+
7+
Web support is currently in an alpha release. This Readme has been updated to reflect updates that are currently only relevant to this alpha release.
8+
9+
### Demo app
10+
11+
The easiest way to test out the alpha is to run the [Supabase Todo-List](./demos/supabase-todolist) demo app:
12+
13+
1. Checkout the powersync.dart repo's `alpha_release`` branch.
14+
* Note: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the project's root and make sure it succeeds.
15+
2. Run `melos prepare` in the project's root
16+
3. cd into the `demos/supabase-todolist` folder
17+
4. If you haven’t yet: `cp lib/app_config_template.dart lib/app_config.dart` (optionally update this config with your own Supabase and PowerSync project details).
18+
5. Run `flutter run -d chrome`
19+
20+
### Installing PowerSync in your own project
21+
22+
Install the latest alpha version of the package, for example:
23+
24+
```flutter pub add powersync:1.3.0-alpha.1```
25+
26+
### Additional config
27+
Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory.
28+
29+
- `sqlite3.wasm` can be found [here](https://github.com/simolus3/sqlite3.dart/releases)
30+
- `powersync_db.worker.js` can be found in the repo's [releases](https://github.com/powersync-ja/powersync.dart/releases) page.
31+
32+
Currently the Drift SQLite library is used under the hood for DB connections. See [here](https://drift.simonbinder.eu/web/#getting-started) for detailed compatibility
33+
and setup notes.
34+
35+
The same code is used for initializing native and web `PowerSyncDatabase` clients.
36+
37+
### Getting started
38+
Follow the [Getting Started](#getting-started) steps further down in this Readme to implement a backend connector and initialize the PowerSync database in your app, and hook PowerSync up with your app's UI.
39+
40+
### Limitations
41+
42+
The API for web is essentially the same as for native platforms. Some features within `PowerSyncDatabase` clients are not available.
43+
44+
Multiple tab support is not yet available. Using multiple tabs will break.
45+
46+
#### Imports
47+
48+
Flutter Web does not support importing directly from `sqlite3.dart` as it uses `dart:ffi`.
49+
50+
Change imports from
51+
52+
```Dart
53+
import 'package/powersync/sqlite3.dart`
54+
```
55+
56+
to
57+
58+
```Dart
59+
import 'package/powersync/sqlite3_common.dart'
60+
```
61+
62+
In code which needs to run on the Web platform. Isolated native specific code can still import from `sqlite3.dart`.
63+
64+
#### Database connections
65+
66+
Web DB connections do not support concurrency. A single DB connection is used. `readLock` and `writeLock` contexts do not
67+
implement checks for preventing writable queries in read connections and vice-versa.
68+
69+
Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent for web) connection is not available. `computeWithDatabase` is not available on web.
70+
471

572
## SDK Features
673

@@ -11,18 +78,18 @@
1178
- No need for client-side database migrations - these are handled automatically.
1279
- Subscribe to queries for live updates.
1380

14-
## Examples
1581

16-
For complete app examples, see our [example app gallery](https://docs.powersync.com/resources/demo-apps-example-projects#flutter)
17-
18-
For examples of some common patterns, see our [example snippets](./example/README.md)
1982

2083
## Getting started
2184

2285
You'll need to create a PowerSync account and set up a PowerSync instance. You can do this at [https://www.powersync.com/](https://www.powersync.com/).
2386

2487
### Install the package
88+
To test web support, install the latest alpha version of the SDK, for example:
89+
90+
```flutter pub add powersync:1.3.0-alpha.1```
2591

92+
If you want to install the latest stable version of the SDK, run:
2693
`flutter pub add powersync`
2794

2895
### Implement a backend connector and initialize the PowerSync database
@@ -155,49 +222,4 @@ Logger.root.onRecord.listen((record) {
155222
});
156223
```
157224

158-
## Web support
159-
160-
Web support is currently in an alpha release.
161-
162-
### Setup
163-
164-
Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. This is typically achieved by placing the files in the project `web` directory.
165-
166-
- `sqlite3.wasm` can be found [here](https://github.com/simolus3/sqlite3.dart/releases)
167-
- `powersync_db.worker.js` can be found in the repo's [releases](https://github.com/powersync-ja/powersync.dart/releases) page.
168-
169-
Currently the Drift SQLite library is used under the hood for DB connections. See [here](https://drift.simonbinder.eu/web/#getting-started) for detailed compatibility
170-
and setup notes.
171-
172-
The same code is used for initializing native and web `PowerSyncDatabase` clients.
173-
174-
### Limitations
175-
176-
The API for web is essentially the same as for native platforms. Some features within `PowerSyncDatabase` clients are not available.
177225

178-
#### Imports
179-
180-
Flutter Web does not support importing directly from `sqlite3.dart` as it uses `dart:ffi`.
181-
182-
Change imports from
183-
184-
```Dart
185-
import 'package/powersync/sqlite3.dart`
186-
```
187-
188-
to
189-
190-
```Dart
191-
import 'package/powersync/sqlite3_common.dart'
192-
```
193-
194-
In code which needs to run on the Web platform. Isolated native specific code can still import from `sqlite3.dart`.
195-
196-
#### Database connections
197-
198-
Web DB connections do not support concurrency. A single DB connection is used. `readLock` and `writeLock` contexts do not
199-
implement checks for preventing writable queries in read connections and vice-versa.
200-
201-
Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent for web) connection is not available. `computeWithDatabase` is not available on web.
202-
203-
Multiple tab support is not yet available. Using multiple tabs will break.

0 commit comments

Comments
 (0)