This demo app is an extension of the Supabase Todo List App and demonstrates the use of the PowerSync SDKs for React Native and Web in a React Native Web project. This configuration allows developers to use one React Native codebase to target mobile and well as web platforms.
This demo uses Sync Streams (edition 3) instead of classic sync rules. Lists are auto-subscribed, while todos are subscribed on-demand when a user opens a specific list and unsubscribed when navigating away.
To use PowerSync in your own React Native for Web project, additional config is required. This is detailed in our docs here.
Prerequisites:
- To run this demo, you need to have properly configured Supabase and PowerSync projects. Follow the instructions in our Supabase<>PowerSync integration guide:
Switch into the demo's directory:
cd demos/react-native-web-supabase-todolistUse pnpm to install dependencies:
pnpm installDetailed instructions for integrating PowerSync with Supabase can be found in the integration guide. Below are the main steps required to get this demo running.
Create a new Supabase project, and paste and run the contents of database.sql in the Supabase SQL editor.
It does the following:
- Create
listsandtodostables. - Create a publication called
powersyncforlistsandtodos. - 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. See instructions here.
Then deploy the following sync streams configuration:
config:
edition: 3
streams:
lists:
query: SELECT _id as id, * FROM lists
auto_subscribe: true
todos:
query: SELECT _id as id, * FROM todos WHERE list_id = subscription.parameter('list_id')Copy the .env.local.template file:
cp .env.local.template .env.localThen edit .env.local to insert your Supabase and PowerSync project credentials.
This is required for the React Native Web implementation. Learn more in our docs.
pnpm powersync-web copy-assetsRun on Web:
pnpm webWeb bundling can take a few seconds.
Run on iOS:
pnpm iosRun on Android:
pnpm android