Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

powersync-ja/powersync-supabase-flutter-todolist-demo

 
 

Repository files navigation

PowerSync + Supabase Flutter Demo: Todo List App

docs-supabase-integration

Demo app demonstrating use of the PowerSync SDK for Flutter together with Supabase. For a step-by-step guide, see here.

Note

This branch differs from the main one by using a Supabase Edge Function for PowerSync authentication of anonymous users.

An example implementation of this function is in the powersync-jwks-example repo.

The app and sync rules are not conceptually designed for anonymous users, so the demo app is not fully functioning.

Running the app

Install the Flutter SDK, then:

flutter pub get
flutter run

Setup Supabase Project

Create a new Supabase project, and paste an run the contents of database.sql in the Supabase SQL editor.

It does the following:

  1. Create lists and todos tables.
  2. Create a publication called powersync for lists and todos.
  3. Enable row level security, allowing users to only view and edit their own data.
  4. Create a trigger to populate some sample data when an user registers.

Setup PowerSync Instance

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

Configure the app

Edit lib/app_config.dart, using the credentials of your new Supabase and PowerSync projects.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •