A simple Expo example demonstrating SQLite synchronization with CloudSync and PostgreSQL. Build cross-platform apps that sync data seamlessly across devices.
sqlite-sync-dev-expo-pg-demo.mp4
Create a new project using this template:
npx create-expo-app MyApp --template @sqliteai/todoapp@dev
cd MyApp- Execute the exact schema from
to-do-app.sql. - Enable CloudSync for all tables on the remote database with:
CREATE EXTENSION IF NOT EXISTS cloudsync; SELECT cloudsync_init('tasks'); SELECT cloudsync_init('tags'); SELECT cloudsync_init('tasks_tags');
- Rename the
.env.exampleinto.envand fill with your values. - If you're testing with a local server define also the
ANDROID_CONNECTION_STRINGvariable and use a different connection string for it, replace localhost with10.0.2.2.
CONNECTION_STRING="http://localhost:8091/postgres"
ANDROID_CONNECTION_STRING="http://10.0.2.2:8091/postgres"
API_TOKEN="token"
- Fill the
API_TOKENvariable with the access token from theCloudSyncservice.
⚠️ SECURITY WARNING: This example puts database connection strings directly in.envfiles for demonstration purposes only. Do not use this pattern in production.Why this is unsafe:
- Connection strings contain sensitive credentials
- Client-side apps expose all environment variables to users
- Anyone can inspect your app and extract database credentials
For production apps:
- Use the secure sport-tracker-app pattern with authentication tokens and row-level security
- Never embed database credentials in client applications
npx expo prebuild # run once
npm run ios # or android- Add Tasks - Create new tasks with titles and optional tags.
- Edit Task Status - Update task status when completed.
- Delete Tasks - Remove tasks from your list.
- Dropdown Menu - Select categories for tasks from a predefined list.
- Cross-Platform - Works on iOS and Android
- Offline Support - Works offline, syncs when connection returns