This package is currently in an alpha release. Functionality could change dramatically in future releases. Certain functions may be partially implemented or buggy.
Demo app demonstrating use of the PowerSync SDK for React Native together with Supabase.
A step-by-step guide on Supabase<>PowerSync integration is available here. (Note: This guide is currently written for Flutter apps; it will be updated for React Native soon)
Install the React Native SDK, then:
yarn install
Run on iOS
yarn ios
Run on Android
yarn android
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, allowing users to only view and edit their own data.
- Create a trigger to populate some sample data when an user registers.
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
Copy the AppConfig.template.ts
to a usable file
cp library/supabase/AppConfig.template.ts library/supabase/AppConfig.ts
Insert the necessary credentials.