powersync 1.3.0-alpha.5 copy "powersync: ^1.3.0-alpha.5" to clipboard
powersync: ^1.3.0-alpha.5 copied to clipboard

PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases.

PowerSync SDK for Dart/Flutter #

PowerSync is a service and set of SDKs that keeps Postgres databases in sync with on-device SQLite databases.

This package (powersync) is the PowerSync SDK for Dart/Flutter clients.

See a summary of features here.

Installation #

flutter pub add powersync

Getting Started #

Our full SDK reference contains everything you need to know to get started implementing PowerSync in your project.

_ Web support - Open alpha _ #

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.

Demo app #

The easiest way to test out the alpha is to run the Supabase Todo-List demo app:

  1. Checkout this repo's alpha_release branch.
  • 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.
  1. Run melos prepare in the repo's root
  2. cd into the demos/supabase-todolist folder
  3. 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).
  4. Run flutter run -d chrome

Installing PowerSync in your own project #

Install the latest alpha version of the package, for example:

flutter pub add powersync:'^1.3.0-alpha.1'

The latest prerelease version can be found here.

Additional config #

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.

  • sqlite3.wasm can be found here
  • powersync_db.worker.js can be found in the repo's releases page.

Currently the Drift SQLite library is used under the hood for DB connections. See here for detailed compatibility and setup notes.

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

Limitations #

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

Multiple tab support is not yet available. Using multiple tabs will break.

Imports

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

Change imports from

import 'package/powersync/sqlite3.dart`

to

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

Web DB connections do not support concurrency. A single DB 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.

Changelog #

A changelog for this SDK is available here.

API Reference #

The full API reference for this SDK can be found here.

Examples #

For example projects built with PowerSync and Flutter, see our Demo Apps / Example Projects gallery. Most of these projects can also be found in the demos/ directory.

Found a bug or need help? #

  • Join our Discord server where you can browse topics from our community, ask questions, share feedback, or just say hello :)
  • Please open a GitHub issue when you come across a bug.
  • Have feedback or an idea? Submit an idea via our public roadmap or schedule a chat with someone from our product team.
47
likes
0
pub points
88%
popularity

Publisher

verified publisherpowersync.com

PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

async, collection, fetch_client, flutter, http, js, logging, meta, sqlite3_flutter_libs, sqlite_async, uuid

More

Packages that depend on powersync