Offline-first mobile apps: why and how

What offline-first apps are, when your app needs to work without signal, and how to build one with a local database, a sync queue and clear conflict rules.

An offline-first app saves everything to a database on the phone first and syncs with the server in the background when a connection is available. The user never waits for the network to tap a button, add a record or open a screen. If the signal drops, the app keeps working, and the changes go up later.

You need this approach when your users work in places with poor signal, when they record things quickly and cannot afford to lose them, or when the app is used many times a day and speed matters. You probably do not need it for an app that is mostly a window onto live data, like a stock price feed or a chat that only makes sense online.

Offline behaviour is something I think about on every app I build, including my own Finlivo apps for expenses, trips and rider earnings, which use React Native, Expo and Supabase. This article explains the reasoning, the architecture, and the parts that take the most care.

Online-first versus offline-first

Most apps are built online-first. When you tap "Save", the app sends a request to the server, waits for a reply, and then updates the screen. That works well on fast Wi-Fi. On a train, in a basement car park or in a rural area, the spinner turns, the request times out, and the user loses what they typed.

An offline-first app flips the order:

Online-firstOffline-first
Write to the server, then show the resultWrite to the local database, show the result immediately
Spinner on every saveNo spinner for local actions
Fails without signalWorks without signal
Server is the only copyPhone has a copy, server has the shared copy
Simpler to buildNeeds a sync layer and conflict rules

The trade-off is real. Offline-first takes more engineering, and more testing. But for the right kind of app, it changes how the product feels.

When an app should be offline-first

Questions I ask clients at the start of a mobile app project:

  • Will people use it somewhere with weak or no signal? Field service, delivery, travel, farms, construction sites, warehouses.
  • Do they enter data quickly and move on? Expense capture, inspections, orders, time tracking.
  • Would losing an entry cause real harm? Money, safety checks, customer records.
  • Is it used many times a day? Waiting even a second on every tap adds up.

If two or more of those are yes, I recommend offline-first. A delivery rider logging earnings between drops, or a traveller adding an expense in an airport with roaming switched off, is exactly the case.

If the app mostly shows data that only makes sense live, a lighter approach works: cache the last loaded data so screens open instantly, and show a clear "You are offline" message for actions that need the server.

The basic architecture

An offline-first app has four parts:

  1. A local database on the phone. In React Native and Expo, that is usually SQLite through expo-sqlite, or a library built on top of it. Small settings can live in simple key-value storage, but real data belongs in a database you can query.
  2. The UI reads from the local database. Screens never wait on the network to display data.
  3. An outbox queue. Every change the user makes is written locally and also recorded as a pending change.
  4. A sync engine. When online, it pushes pending changes to the server, then pulls changes made elsewhere (another device, another team member) and applies them locally.

There are ready-made sync tools that do much of this for you. Some work directly with Postgres and Supabase. They can save a lot of time, but they also add a dependency and their own pricing, so I weigh that per project. For simpler data models, a hand-written sync layer with clear rules is very manageable.

Rules that make sync reliable

The sync engine is where offline apps succeed or fail. These are the rules I follow.

Generate IDs on the device. Use UUIDs created on the phone when a record is made. If you wait for the server to assign an ID, you cannot link records together while offline.

Track when each record changed. Every row gets an updated_at timestamp and, ideally, the ID of the device that changed it. This lets the sync engine pull only what changed since the last sync.

Never hard-delete. Mark records as deleted with a deleted_at field instead. If you delete a row on one phone, the other devices need to learn about that deletion. A missing row tells them nothing.

Make every push safe to retry. Networks fail halfway through. If the app sends the same change twice, the server should end up in the same state. Upserts by ID handle this naturally.

Push before pull. Send local changes first, then fetch remote ones. That avoids overwriting the user's newest work with an older server copy.

A simplified outbox flow in TypeScript looks like this:

async function syncOnce() {
  const pending = await db.getAllAsync(
    'SELECT * FROM outbox ORDER BY created_at LIMIT 50'
  );

  for (const change of pending) {
    const { error } = await supabase
      .from(change.table_name)
      .upsert(JSON.parse(change.payload));

    if (error) return; // stop and retry on the next sync
    await db.runAsync('DELETE FROM outbox WHERE id = ?', change.id);
  }

  await pullRemoteChanges(); // fetch rows updated since last sync
}

Real code adds batching, backoff on errors and a lock so two syncs never run at once, but the shape stays the same.

Handling conflicts

A conflict happens when the same record is changed on two devices before either has synced. You need a rule, decided up front, for which change wins.

  • Last write wins. The most recent change overwrites the other. Simple and fine for most personal data.
  • Field-level merging. If one device changed the amount and another changed the note, keep both. More work, better for shared records.
  • Append-only records. For things like payments or log entries, never edit, only add. Conflicts mostly disappear.
  • Ask the user. Rarely worth it, but sometimes right for important shared documents.

For finance-style apps, I lean heavily on append-only data where I can. It is easier to reason about and easier to audit.

Security and storage on the device

Data on the phone needs the same care as data on the server:

  • Keep the session token in secure storage (expo-secure-store), not in plain storage.
  • Clear the local database on sign-out, and make sure a different user signing in on the same phone cannot see the previous data.
  • On the server, use row level security so a user can only sync their own records, whatever the app sends. Supabase's row level security guide covers this.
  • Plan local database migrations. When you add a column in version 2, the app must upgrade the existing database on phones still holding version 1 data.

Testing an offline-first app

Test the unhappy paths on purpose:

  1. Turn on airplane mode, add and edit records, then reconnect.
  2. Kill the app mid-sync and reopen it.
  3. Edit the same record on two devices offline, then bring both online.
  4. Sign out and sign in as a different user on the same device.
  5. Install an old version, add data, then update to the new version.

Most of the bugs I have seen in offline apps appear in one of those five tests.

The short version

Offline-first means the phone's database is the source of truth for the screen, and the server is synced in the background. Use it when users work with poor signal, enter data quickly, or cannot afford to lose entries. Build it with a local SQLite database, an outbox queue, device-generated IDs, soft deletes, retry-safe pushes and a clear conflict rule.

If you are planning an app that needs to work anywhere, you can see the kind of app I build in Finlivo Business, or contact me to talk through your own project.

Available for new projects

Need a hand with this?

Tell me what you need: a new site, a fix, a SaaS or an app. You'll get a clear plan and price within a day.

Start a project WhatsApp me