Engineering
Building apps that work without signal: offline-first lessons from Kenya
How we build apps for shops, field officers and riders who lose signal and run out of bundles, using Duka Tracker and FieldWatch as examples.
Most apps are designed in an office with fast Wi-Fi and tested on a recent phone. Then they ship to a shop in Kawangware, a field officer in Turkana or a rider in Thika, where the signal drops, bundles run out and the phone has 2 GB of RAM and a nearly full storage.
If the app only works online, it fails exactly when people need it. This post covers how we build software that keeps working anyway, using two of our own products as examples: Duka Tracker, a point-of-sale and bookkeeping app for small shops, and FieldWatch, a monitoring tool for water and sanitation field officers.
Start from the worst realistic day
Before we design anything, we write down the worst normal day for the main user. Not a disaster, just a bad Tuesday.
For a shopkeeper using Duka Tracker it looks like this: the phone is an entry-level Android, the bundle ran out at 11am, there are customers waiting, and the shop needs to record twenty sales before the owner can top up. If the app shows a spinner when the network drops, the shopkeeper goes back to the exercise book and never opens the app again.
That one paragraph decides most of the architecture.
The local device is the first database
In an offline-first app, every action is saved on the phone first and sent to the server later. The user never waits for the network to finish a sale, record a visit or add a product.
For web apps and PWAs we use IndexedDB in the browser. Every change gets written to a local store and to an outbox queue at the same moment. A sync worker drains that queue whenever the device is online. The screen reads from local data, so it updates instantly whether there is signal or not.
Give every record its own ID on the device
If the server assigns IDs, an offline device cannot create a record and refer to it straight away. A sale needs to point to the items in it before the server has ever seen them.
So the device generates IDs itself, using UUIDs or a similar scheme. When the record reaches the server it keeps the same ID. Duplicates from retries are easy to detect, and nothing has to be renumbered after sync.
Decide how conflicts are resolved before they happen
Two people edit the same record while offline. Who wins? There is no universal answer, but there must be a written one.
The rules we use most:
- Append, do not overwrite, for anything financial. A sale, a payment or a stock adjustment is a new entry, never an edit to a total. Two offline devices can both add entries and nothing is lost. Stock on hand is calculated from movements.
- Last write wins for simple fields like a phone number or a product description, with the change history kept.
- Ask a human when two edits genuinely contradict each other and it matters, for example two different readings for the same water point on the same day.
Most "sync bugs" we get asked to fix in other teams' apps are really missing rules.
Make sync state visible but calm
Users should always be able to tell whether their work is safe. We show a small indicator such as "All changes saved" or "12 changes waiting to sync", and never a blocking dialog. If something fails permanently, the item gets flagged and the user is told in plain words what to do about it.
What we avoid: silent failures, and the opposite, alarming red banners every time the signal drops for ten seconds.
Respect the user's data bundle
Data costs real money for most of our users. A few habits make a big difference:
- Send only what changed since the last sync, not whole lists.
- Compress images on the phone before uploading. A 4 MB photo of a water point can usually be 200 KB without losing anything useful.
- Cache the app shell and assets with a service worker so the app opens without downloading itself again.
- Let users choose to sync photos on Wi-Fi only.
Test on the phones people actually use
We keep a few low-end Android phones in the studio and test on them before every release, with the network throttled or switched off. Chrome DevTools throttling helps, but nothing replaces a real cheap phone with a full gallery and twenty apps running in the background.
Things that only show up on real devices: storage quota errors, the browser killing a background tab mid-sync, and keyboards covering half the form.
When there is no smartphone at all
Sometimes the right answer is not an app. For PitchLine, a grassroots sports platform we built for the Africa's Talking Women in Tech Hackathon, a lot of the audience uses feature phones. So the core actions work over USSD on any phone, and a PWA adds a richer experience for those with smartphones. Both talk to the same backend.
USSD sessions are short and every screen costs money, so menus need to be shallow and wording very tight. It is a different design discipline, and a valuable one.
What this costs
Offline-first adds real work: local storage, a sync engine, conflict rules and extra testing. On a typical project we see it add somewhere around 20 to 35% to the build, depending on how much data moves and how complex the conflicts are.
For apps used in the field, in shops or on the move, that is cheap compared with the cost of an app nobody trusts. For an internal dashboard used in an office, it is usually not worth it. Part of our job is telling you which one you are building.
If you are planning a field, retail or logistics app, our mobile app and web application teams build this way by default. You can also get a quick estimate from our pricing calculator.
Have a project like this in mind?
Elom Labs is a Nairobi software studio. We have delivered 68 projects since 2023, and first-time clients get 20% off their first project.