|
| 1 | +# Expo CloudSync Example |
| 2 | + |
| 3 | +A simple Expo example demonstrating SQLite synchronization with CloudSync and PostgreSQL. Build cross-platform apps that sync data seamlessly across devices. |
| 4 | + |
| 5 | +<img src="https://github.com/user-attachments/assets/86db5c25-d8ff-4c31-b157-8dff178e1720" width="40%" height="40%"> |
| 6 | + |
| 7 | +## 🚀 Quick Start |
| 8 | + |
| 9 | +### 1. Clone the template |
| 10 | + |
| 11 | +Create a new project using this template: |
| 12 | +```bash |
| 13 | +npx create-expo-app MyApp --template @sqliteai/todoapp@dev |
| 14 | +cd MyApp |
| 15 | +``` |
| 16 | + |
| 17 | +### 2. Setup |
| 18 | + |
| 19 | +1. Execute the exact schema from `to-do-app.sql`. |
| 20 | +2. Rename the `.env.example` into `.env` and fill with your values. |
| 21 | +3. If you're testing with a local server define also the `ANDROID_CONNECTION_STRING` variable and use a different connection string for it, replace localhost with `10.0.2.2`. |
| 22 | + |
| 23 | +``` |
| 24 | +CONNECTION_STRING="http://localhost:8091/postgres" |
| 25 | +ANDROID_CONNECTION_STRING="http://10.0.2.2:8091/postgres" |
| 26 | +API_TOKEN="token" |
| 27 | +``` |
| 28 | + |
| 29 | +4. Fill the `API_TOKEN` variable with the token from the `CloudSync` service. |
| 30 | + |
| 31 | +> **⚠️ SECURITY WARNING**: This example puts database connection strings directly in `.env` files for demonstration purposes only. **Do not use this pattern in production.** |
| 32 | +> |
| 33 | +> **Why this is unsafe:** |
| 34 | +> - Connection strings contain sensitive credentials |
| 35 | +> - Client-side apps expose all environment variables to users |
| 36 | +> - Anyone can inspect your app and extract database credentials |
| 37 | +> |
| 38 | +> **For production apps:** |
| 39 | +> - Use the secure [sport-tracker-app](https://github.com/sqliteai/sqlite-sync-dev/tree/main/examples/sport-tracker-app) pattern with authentication tokens and row-level security |
| 40 | +> - Never embed database credentials in client applications |
| 41 | +
|
| 42 | +### 4. Build and run the App |
| 43 | + |
| 44 | +```bash |
| 45 | +npx expo prebuild # run once |
| 46 | +npm run ios # or android |
| 47 | +``` |
| 48 | + |
| 49 | +## ✨ Features |
| 50 | + |
| 51 | +- **Add Tasks** - Create new tasks with titles and optional tags. |
| 52 | +- **Edit Task Status** - Update task status when completed. |
| 53 | +- **Delete Tasks** - Remove tasks from your list. |
| 54 | +- **Dropdown Menu** - Select categories for tasks from a predefined list. |
| 55 | +- **Cross-Platform** - Works on iOS and Android |
| 56 | +- **Offline Support** - Works offline, syncs when connection returns |
| 57 | + |
0 commit comments