Offline-first, in plain words
What it really means for an app to work without internet, and the three ideas that make it possible.
Most apps are online-first. You tap a button, the app calls a server, and it waits. No internet means a spinner, then an error.
An offline-first app flips this. It works fully on the phone first, and talks to the server when it can. I learned this while building a field-survey app. The people using it worked at gas sites, where the signal comes and goes all day.
Three ideas make it work.
1. The local database is the truth
In an online-first app, the server is the truth and the app just shows it. In an offline-first app, the local database on the phone is the truth for the screen.
- The UI only reads from the local database. Never straight from the network.
- When fresh data comes from the server, you save it into the database first. The UI then updates on its own, because it is watching the database.
2. Every change goes into an outbox
When the user saves something offline, you can't send it yet. So you write it in two places, in one transaction:
- The real table (so the UI shows it right away).
- An outbox table: a to-do list of changes the server hasn't seen yet.
CREATE TABLE outbox (
id TEXT PRIMARY KEY, -- a UUID made on the phone
table_name TEXT NOT NULL, -- which table changed
row_id TEXT NOT NULL, -- which row changed
created_at INTEGER NOT NULL
);A background job wakes up when the internet is back, sends each outbox row to the server, and deletes it after the server says "OK".
Two small rules save a lot of pain:
- Make IDs on the phone (UUIDs). Then you never have to wait for the server to give a new row its ID.
- Use a transaction when one save touches many tables. A survey with 4 steps should land in the database completely, or not at all.
3. Download only what changed
Apps also need reference data from the server: lists of places, products, meter types. Downloading everything every time is slow and expensive on mobile data.
Instead, remember when you last synced, and ask only for what changed since then:
GET /master-data?updated_after=2026-11-27T10:30:00ZThis is called a delta sync. The first sync is big. Every sync after that is tiny.
What gets harder
Offline-first is not free. You now have to think about:
| Problem | Simple first answer |
|---|---|
| Two people edit the same row | Decide a rule early, e.g. "last write wins" |
| A sync fails halfway | Keep the outbox row, try again later |
| The database schema changes | Write migrations and test them on old data |
The short version
- The phone's database is the truth for the screen.
- Saves go to the database and an outbox, in one transaction.
- A background job pushes the outbox and pulls only what changed.
If your users ever stand in a basement, a village or a lift, this is worth it.