examples/react-native/shopping-list
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
React Native Shopping List (Electric + Persistence + Offline Queue)#
This example uses:
electricCollectionOptionsfor realtime sync from Electric shape streamspersistedCollectionOptionswith React Native SQLite persistence@tanstack/offline-transactionsfor queued optimistic mutations and retry- A local Express + Postgres API that returns
txidvalues for Electric mutation matching - Dedicated API shape proxy endpoints (
/api/shapes/*) so Electric is not exposed directly to clients - In-app
Simulate offlinetoggle to demo offline queue + persistence behavior without disabling device network
Run#
From examples/react-native/shopping-list:
- Start Docker Desktop (required for Postgres + Electric).
- Start Postgres + Electric:
pnpm db:up
- Start the API server in a separate terminal:
pnpm server
- Start Expo in another terminal:
pnpm start
- Launch iOS simulator:
open -a Simulator- then press
iin the Expo terminal (or runpnpm ios)
- Launch Android emulator:
- start an AVD from Android Studio Device Manager
- then press
ain the Expo terminal (or runpnpm android)
Troubleshooting#
- If the server exits at startup, ensure Docker services are running and re-run
pnpm db:up. - Android emulator uses
10.0.2.2for local host mapping. - iOS simulator uses
localhost.
Verification checklist#
- Add list and items while online: changes should sync and persist.
- Restart app: local data should load from SQLite immediately.
- Restart API/Electric: app should recover and continue syncing.
- Confirm there are no
Date value out of boundserrors in shape sync logs.