Skip to content

Commit 8b23cbb

Browse files
committed
Add EXPO example to docs/postgresql
1 parent 33be888 commit 8b23cbb

2 files changed

Lines changed: 58 additions & 2 deletions

File tree

docs/postgresql/CLIENT.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ Under the hood, SQLite Sync uses advanced **CRDT (Conflict-free Replicated Data
2222

2323
- Updated example apps are available [here](https://github.com/sqliteai/sqlite-sync-dev/tree/main/examples):
2424
- sport-tracker app (WASM), see [SPORT_APP_README_SUPABASE.md](SPORT_APP_README_SUPABASE.md) for more details
25-
- to-do app (Expo)
25+
- to-do app (Expo), see [EXPO.md](EXPO.md) for more details
2626
- React Native Library: https://github.com/sqliteai/sqlite-sync-react-native
27-
- Remaining demos will be updated in the next days
2827

2928
## Conversion Between SQLite and PostgreSQL Tables
3029

docs/postgresql/EXPO.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)