Prompt
How do I choose a backend for a React Native app with offline sync?
Latest observation
Choosing a backend for a React Native app with offline sync comes down to how much sync logic you want to own versus how much you want the backend to provide for you.
1) Start with your sync requirements
Ask these first:
- Is offline-first mandatory, or just “nice to have”?
- How complex is conflict resolution?
- Simple last-write-wins?
- Field-level merges?
- User-facing conflict resolution?
- How much data needs offline access?
- Small set of user-specific records?
- Large datasets?
- Do you need realtime collaboration or just eventual sync?
- Do you need multi-device sync with the same user account?
- Do you need backend business logic beyond CRUD?
Your answers will narrow the options quickly.
2) Common backend choices
Option A: Backend-as-a-Service with built-in/offline sync
Best if you want to move fast and avoid building sync infrastructure.
Examples
- Firebase / Firestore
- Realm Sync / MongoDB Atlas Device Sync
- Couchbase Lite + Sync Gateway
- AWS Amplify DataStore / AppSync
- RxDB with a sync endpoint
- PowerSync (sits between your DB and app, focused on sync)
Good for
- Fast development
- Simple to moderate sync needs
- Mobile-first apps
- Teams that want less backend code
Tradeoffs
- Vendor lock-in
- Sync model may constrain your data design
- Complex querying or advanced conflict logic can be harder
- Cost can grow with usage
Option B: Custom backend + local database + sync layer
Best if your app has custom business rules or you want full control.
Typical stack
- React Native app
- Local DB: SQLite, WatermelonDB, Realm, MMKV for small state
- Backend API: Node.js/Express, NestJS, Go, Rails, etc.
- Sync mechanism:
- delta sync
- change tracking
- versioning / timestamps
- conflict resolution
Good for
- Highly customized apps
- Strong backend logic requirements
- Complex permissions and data models
- Avoiding vendor lock-in
Tradeoffs
- More engineering effort
- You must design conflict handling, retries, and schema evolution
- More testing burden
3) A practical decision framework
Choose Firebase/Firestore if:
- Your data model is document-friendly
- You want realtime updates and quick setup
- Offline behavior can be mostly automatic
- You can live with Firestore’s query/index constraints
Choose Realm if:
- You want a local-first database model
- Your app needs strong offline performance
- Your data is deeply relational or object-oriented
- You’re okay with Realm/MongoDB ecosystem coupling
Choose Couchbase if:
- You need robust offline sync and edge/mobile synchronization
- You have more complex distributed data needs
- You’re comfortable with its architecture and operational overhead
Choose AWS Amplify/AppSync if:
- You’re already on AWS
- You want GraphQL-based syncing
- You need scalable managed infrastructure
- You can align your app with AppSync’s sync patterns
Choose custom backend + SQLite/WatermelonDB if:
- You need full control over sync and business rules
- You have unusual conflict handling or security rules
- You expect the sync logic to evolve significantly
- You have backend engineering resources
4) Evaluate these backend criteria
Offline behavior
Look for:
- local persistence
- queued writes
- automatic retries
- background sync
- conflict resolution support
Data model fit
- Document DBs are often easiest for mobile sync
- Relational models are fine, but sync becomes more complex
- If your app depends on joins and transactional consistency, plan carefully
Conflict handling
Ask:
- Does the platform support conflict detection?
- Can you define merge strategies?
- Can users edit the same record from multiple devices?
Security
You need:
- auth
- row-level or record-level access control
- sync only authorized data
- auditability if needed
Scalability and cost
Check:
- write amplification
- sync traffic costs
- storage costs
- egress costs
- vendor pricing as usage grows
Developer experience
Consider:
- SDK quality
- TypeScript support
- debugging tools
- local dev workflow
- testability
5) A good default recommendation
If you’re unsure:
- Simple app, fast MVP: Firebase/Firestore
- Need robust offline-first with mobile-local DB: Realm or Couchbase
- Already on AWS and want managed sync: Amplify/AppSync
- Need maximum control: custom backend + SQLite/WatermelonDB + sync API
6) A common architecture that works well
For many React Native apps:
- Local DB on device: SQLite or WatermelonDB
- API backend: REST or GraphQL
- Sync protocol:
- pull changes since last sync token
- push local mutations
- resolve conflicts by version/timestamp/merge rules
- Auth: JWT/OAuth
- Background sync: app resume, periodic tasks, network reconnect
This gives you flexibility and good offline UX, but requires more implementation.
7) My advice
If offline sync is core to the product, don’t choose based only on “backend popularity.” Choose based on:
- sync complexity
- conflict strategy
- data model
- team expertise
- lock-in tolerance
If you want, I can help you narrow it down by asking 5–6 questions and then recommend a backend stack for your specific app.