What is offline-first
& why does it matter?
Your app is loading. The spinner keeps spinning. A basement office, a job site with no reception, a subway commute — the connection drops and your tool becomes useless.
"Building software that depends on constant internet access is building software that fails exactly when users need it most. We designed onbalance around a different principle: your device knows your data first, and the network catches up when it can."
Offline-first benefits for users
Offline-first means the app reads and writes to local device storage first. The network is an optimization, not a requirement. Users interact with data on their device immediately. Background operations sync with remote servers when a connection is available. Traditional apps block user actions until the server responds. Offline-first apps don't.
In one sentence: Offline-first means your app works even without internet, saving everything on your device first and syncing when it can.
Offline-first isn't a buzzword. It's what you notice when your app just works. Your data is always available, your changes are saved, and you don't have to worry about losing your connection.
How offline-first architecture works: local data as the primary source
The local database is the single source of truth. The UI reads from and writes to local storage first, never waiting for network responses to display data or confirm actions. The server stores encrypted changes and relays them between devices through background sync.
The read path is different from traditional REST or GraphQL. Instead of network requests that block the UI, the application observes a reactive stream from the local database. Data appears instantly from cache. If the device is online, a background process fetches fresh data from the server and merges it into local storage. The UI updates automatically through the observer pattern.
The write path works the same way in reverse. User input persists to the local database immediately. The UI confirms success before any network activity. The system marks these records as pending and queues them for transmission. Platform-level background task schedulers handle the actual network operations, batching requests when conditions are good, such as when WiFi is connected or the device is charging.
Managing data sync, fetching, and writing in offline-first systems
Here's how data flows through an offline-first system, from the moment a user taps "save" to the moment the server has the record:
-
1
Write data locally immediately (optimistic UI).
The app persists the record to the local database and updates the interface to show success, all before any network activity. No perceived latency. -
2
Track changes as operations or records.
Each modification creates a trackable record in the model layer. The system records timestamps, operation types, and unique identifiers to support conflict recognition later. -
3
Queue outbound writes and schedule retries.
Pending changes enter a persistent queue. The sync engine monitors network availability and device conditions, transmitting when optimal. Failed attempts trigger exponential backoff with jitter to prevent server overload. -
4
Fetch data deltas when online.
Rather than downloading complete datasets, delta sync transfers only changed records since the last sync cursor.
-
5
Resolve conflicts deterministically.
When the same record changes on multiple devices, the system applies a predefined strategy (last write wins, field-level merge, or other CRDT-based mechanisms) without requiring user intervention in most cases. CRDTs tend to be the best default here: they merge concurrent edits automatically and converge to the same state even if updates arrive late or out of order. That's why we chose a CRDT-based approach in onbalance. -
6
Confirm sync and update state.
Once the server acknowledges receipt, the record is marked as fully synced.
Security and privacy considerations for offline data
Storing data on-device changes the threat model. In a server-only app, you defend one perimeter. In offline-first, every device is a perimeter.
Here are the principles that matter:
- Encrypt data at rest. The local database should be encrypted so that a lost or stolen device doesn't mean exposed records. Platform-level encryption tied to device credentials offers another layer.
- Protect encryption keys. Keys should live in the device's secure enclave — never in plaintext alongside the data they protect.
- Propagate deletions. When a user deletes data (or exercises GDPR right-to-delete), the deletion must reach every synced device, not just the server.
-
Maintain audit trails. Append-only operation logs, with cryptographic integrity checks and server-side verification of sequence and delivery receipts, provide tamper resistance and compliance traceability.
With end-to-end encrypted sync, the server can't verify the plaintext contents of an audit log. But it can still verify metadata and integrity signals such as ordering/sequence, signatures, and delivery receipts.
- Enforce device access policies. Require a device passcode or biometric lock before the app can access sensitive local data.
The distinction between "secure" and "private" matters here. A finance app can encrypt everything and still let the provider read your data server-side. For a deeper look at how this applies to financial tools, see what makes a finance app truly "privacy-first".
When offline-first is the right choice (and when it's not)
Offline-first suits specific use cases. Forcing it where it doesn't belong adds complexity for no gain.
To understand when offline-first makes sense, consider the limits of classic cloud-first apps:
These limitations make offline-first the obvious choice in certain scenarios:
Best-fit use cases
When online-first is the better choice
What offline-first means in onbalance
onbalance uses these offline-first ideas to help small businesses, freelancers, and project teams track their cash flow.