Prompt
What should I use for offline sync in a mobile app backend?
Latest observation
For offline sync in a mobile app backend, the best choice depends on how much conflict handling, flexibility, and scale you need. Here are the main options:
Good choices by use case
1) Firebase / Firestore
Best if you want the fastest path to production.
Pros
- Built-in offline support on mobile
- Real-time sync
- Easy to use
- Great for prototypes and many production apps
Cons
- Conflict resolution is limited and app-specific
- Can get expensive at scale
- Query limitations can be awkward
Use if:
You want a managed solution and your data model fits Firestore well.
2) Supabase + custom sync
Best if you want Postgres and more control.
Pros
- Uses Postgres
- Easier to query than Firestore
- Open source / self-hostable
- Good backend foundation
Cons
- Offline sync is not fully built in
- You’ll need to build sync logic or use a library
Use if:
You want SQL and control, and are okay implementing sync yourself.
3) Couchbase Mobile / CouchDB-style replication
Best if offline sync is the core requirement.
Pros
- Designed specifically for offline-first apps
- Built-in bidirectional replication
- Conflict handling support
- Good for mobile-centric architectures
Cons
- More specialized stack
- Less common than Firebase/Postgres
- More operational complexity
Use if:
Offline sync is a central product requirement and you want robust replication.
4) Realm Sync
Best if you want a mobile-native offline database with sync.
Pros
- Very good local-first mobile experience
- Sync is built in
- Strong performance
Cons
- Tied to MongoDB ecosystem / Atlas setup
- Vendor lock-in considerations
- Less flexible than DIY Postgres approaches
Use if:
You want mobile offline-first with minimal client-side sync work.
5) Custom sync over Postgres + change log
Best if you need full control and have complex business rules.
Typical pattern:
- Local DB on device (SQLite)
- Backend stores canonical data in Postgres
- Sync endpoint exchanges:
- local changes pushed up
- remote changes pulled down
- version/timestamp/vector-clock metadata
- Conflict resolution handled by your rules
Pros
- Maximum flexibility
- Works with existing backend
- Can be optimized for your app’s semantics
Cons
- Hard to build correctly
- Conflict resolution is tricky
- More engineering time
Use if:
Your app has custom workflows or strict domain logic.
Practical recommendation
If you’re unsure, choose based on this:
- Simple app / MVP: Firebase Firestore
- Need SQL / existing backend: Postgres + custom sync
- Offline-first is core: Couchbase Mobile or Realm Sync
- Want open-source and flexibility: Supabase + custom sync layer
If you want the “most common good architecture”
A solid pattern is:
- Mobile app local DB: SQLite
- Backend DB: Postgres
- Sync API: incremental changes using
updated_at, version numbers, or change feed - Conflicts: resolve with server-side rules or per-field merge logic
This gives you a durable, scalable setup without locking you into a proprietary sync model.
If you tell me:
- your backend stack,
- whether you need real-time sync or just eventual sync, and
- how complex your conflicts are,
I can recommend the best specific tool and architecture.