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.
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 and storage policies, allowing users to only view and edit their own data.
- Create a trigger to populate some sample data when a user registers.
Create a new PowerSync instance, connecting to the database of the Supabase project (find detailed instructions in the Supabase<>PowerSync integration guide).
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
Replace the necessary credentials in the .env file.
Generally, the .env
file is used for storing common environment variables shared across all instances of the application, while .env.local
is for overriding or providing environment-specific configurations, particularly for local development.
As .env.local
is normally not checked into source control (this project has a git-ignore rule), you can copy .env
, name it .env.local
, and then configure as needed.
Take note that you will need an Expo account if you want to use EAS for your builds. The Expo project ID should then also be configured in the environment file.
For secret/sensitive environment variables which shouldn't be checked into source control, you can configure them as EAS secrets. They can be added via either the Expo website or the EAS CLI, both are explained here.
General information on defining environment variables with Expo can be found here here.
Install the dependencies, including the React Native SDK:
pnpm i
Run on iOS
pnpm ios
Run on Android
pnpm android