Demo app demonstrating use of the PowerSync SDK for Flutter together with a custom Node.js backend and using Firebase for user auth on the client.
This repo can run alongside the powersync-nodejs-firebase-backend-todolist-demo for testing and demo purposes.
We suggest you first set up the powersync-nodejs-firebase-backend-todolist-demo
before setting up the client as shown in this repo.
Install the Flutter SDK, then:
flutter pub get
flutter run
Follow the step found in this page from the Firebase docs to login to your Firebase account and to initialize the Firebase credentials.
Create a new Supabase project, and paste and run the contents of database.sql in the Supabase SQL editor.
It does the following:
- Create
lists
andtodos
tables. - Create a publication called
powersync
forlists
andtodos
. - Enable row level security (RLS), allowing users to only view and edit their own data.
- Create a trigger to populate some sample data when a user registers.
We won't be using the Supabase Flutter SDK for this demo, but rather as a hosted PostgresSQL database that the app connects to.
Create a new PowerSync instance, connecting to the database of the Supabase project.
Then deploy the following sync rules:
bucket_definitions:
user_lists:
# Separate bucket per todo list
parameters: select id as list_id from lists where owner_id = token_parameters.user_id
data:
- select * from lists where id = bucket.list_id
- select * from todos where list_id = bucket.list_id
Edit lib/app_config.dart, using the credentials of your new Supabase and PowerSync projects.