Fullstack Developer with experience building web and mobile apps using React, Next.js, React Native, and TypeScript. Based in North Macedonia.

Back to Blog
Offline FirstSQLiteMobile

Local-First: Building Offline-Ready Apps with SQLite

Muiz Rexhepi

Connectivity is a feature, not a guarantee. For Insylink, our POS system, "offline mode" is the default state. We built a local-first architecture that prioritizes instant user feedback over server confirmation.

The Stack: Expo SQLite + Drizzle

We use Expo SQLite as our single source of truth. By pairing it with Drizzle ORM, we get type-safe SQL queries directly on the device. When a waiter punches in an order, it writes to SQLite immediately.

Sync Engine & Optimistic UI

We implemented a "Sync Queue" pattern. Every mutation is wrapped in a job that is:

  1. Applied optimistically to the UI.
  2. Persisted to a local mutation_queue table.
  3. Processed by a background worker when the network is reachable.

Conflict Resolution

What happens if two devices edit the same order offline? We utilize a simplified CRDT (Conflict-free Replicated Data Type) approach. Instead of saving "User X set quantity to 5", we save "User X added 2 items". Commutative operations allow us to merge changes from multiple offline devices without data loss when they finally reconnect.