Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions client-sdk-references/flutter/flutter-web-support.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: "Flutter Web Support (Alpha)"
title: "Flutter Web Support (Beta)"
---

Web support for Flutter in version `^1.6.0` is currently in its alpha stage.
Web support for Flutter in version `^1.9.0` is currently in its alpha stage.

## Demo app

The easiest way to test out the alpha is to run the [Supabase Todo-List](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist) demo app:
The easiest way to test Flutter Web support is to run the [Supabase Todo-List](https://github.com/powersync-ja/powersync.dart/tree/main/demos/supabase-todolist) demo app:

1. Checkout [the powersync.dart repo's](https://github.com/powersync-ja/powersync.dart/tree/master) `master` branch.
1. Checkout [the powersync.dart repo's](https://github.com/powersync-ja/powersync.dart/tree/main) `main` branch.
1. **Note**: If you are an existing user updating to the latest code after a git pull, run `melos exec 'flutter pub upgrade'` in the repo's root and make sure it succeeds.
2. Run `melos prepare` in the repo's root
3. cd into the `demos/supabase-todolist` folder
Expand All @@ -20,22 +20,26 @@ The easiest way to test out the alpha is to run the [Supabase Todo-List](https:/
Install the latest alpha version of the package, for example:

```bash
flutter pub add powersync:'^1.6.2'
flutter pub add powersync:'^1.9.0'
```

The latest version can be found [here](https://pub.dev/packages/powersync/versions).

## Additional config

Web support requires `sqlite3.wasm` and `powersync_db.worker.js` assets to be served from the web application. They can be downloaded to the `web` directory by running the following command in your application's root folder.
Web support requires `sqlite3.wasm` and worker (`powersync_db.worker.js` and `powersync_sync.worker.js`) assets to be served from the web application. They can be downloaded to the web directory by running the following command in your application's root folder.

```bash
dart run powersync:setup_web
```

The same code is used for initializing native and web `PowerSyncDatabase` clients.

## Imports
## Limitations

The API for Web is essentially the same as for native platforms, however, some features within `PowerSyncDatabase` clients are not available.

### Imports

Flutter Web does not support importing directly from `sqlite3.dart` as it uses `dart:ffi`.

Expand All @@ -53,14 +57,9 @@ import 'package/powersync/sqlite3_common.dart'

in code which needs to run on the Web platform. Isolated native-specific code can still import from `sqlite3.dart`.

## Database connections
### Database connections

Web database connections do not support concurrency. A single database connection is used. `readLock` and `writeLock` contexts do not implement checks for preventing writable queries in read connections and vice-versa.

Direct access to the synchronous `CommonDatabase` (`sqlite.Database` equivalent for web) connection is not available. `computeWithDatabase` is not available on web.

## Limitations

The API for web is essentially the same as for native platforms. Some features within `PowerSyncDatabase` clients are not available.

Full multiple tab support is not yet available. Some sync status indicators will not be available in each tab. Multiple requests from tabs to connect/disconnect might result in undefined behaviour.