A mobile application cannot assume that its users will always have a reliable internet connection.
Users move between networks, enter areas with poor connectivity, enable airplane mode or experience temporary server outages. An application that depends on a successful network request for every interaction can quickly become frustrating to use.
An offline-first architecture addresses this problem by treating local data access as a primary application capability rather than an emergency fallback.
This article explores the architectural decisions involved in building reliable offline-first mobile applications.
1. Start with the User Experience, Not the Database
Before selecting a local database or synchronisation strategy, identify which application features must remain available without connectivity.
Consider a task management application.
Users might need to:
- View previously loaded tasks.
- Create new tasks.
- Edit existing information.
- Mark tasks as complete.
- Search locally available records.
However, they cannot necessarily synchronise changes with other devices until connectivity returns.
This distinction helps define which operations can be completed locally and which require remote confirmation.
A useful starting point is to classify application operations into three groups:
| Operation type | Offline behaviour |
|---|---|
| Read operations | Use locally available data |
| Local write operations | Save changes locally and queue synchronisation |
| Server-dependent operations | Display an appropriate pending or unavailable state |
This prevents the application from presenting every network failure as a complete application failure.
2. Establish a Local Source of Truth
A common architectural mistake is allowing UI components to depend directly on network responses.
Instead, the application can use a local data source as the primary source of information presented to the interface.
A simplified data flow looks like this:
UI β ViewModel or presentation layer β Repository β Local data source
The repository coordinates local and remote operations.
For example, when a user opens a task list, the application reads the locally stored records and displays them immediately.
The repository can then request updated information from the backend.
When new information arrives, the local database is updated, and the interface observes the changes.
This approach separates data access from presentation and makes offline behaviour easier to reason about.
3. Design Synchronisation as a Separate Responsibility
Offline-first applications need a reliable way to reconcile local changes with remote data.
A synchronisation process may need to:
- Identify pending local changes.
- Prepare records for upload.
- Send changes to the backend.
- Handle successful responses.
- Process rejected or conflicting updates.
- Update local synchronisation status.
A common approach is to maintain a queue of pending operations.
Each operation can include an identifier, the affected record, the intended change and relevant metadata.
The queue should survive application restarts so that pending changes are not lost.
However, simply retrying every failed request indefinitely is not sufficient.
The application needs retry limits, backoff strategies and clear handling for permanent failures.
4. Conflict Resolution Needs an Explicit Strategy
What happens when the same record changes on two different devices while one device is offline?
For example:
- Device A changes a task's deadline.
- Device B changes the task's description.
- Both devices synchronise later.
The backend and application need a defined conflict-resolution policy.
Possible approaches include:
Last-write-wins: The most recent accepted update takes precedence. This is relatively straightforward but can overwrite useful changes.
Field-level merging: Changes to different fields can be combined when they do not conflict.
Version-based conflict detection: The system detects that the record changed since the client last retrieved it and requests a resolution.
User-assisted resolution: The application presents conflicting versions when automatic resolution is unsafe.
The appropriate strategy depends on the business rules and the importance of the data.
A collaborative editing product, for example, has very different requirements from a personal checklist application.
5. Handle Network Changes and Background Synchronisation
Connectivity is not simply an online/offline switch.
A device may move between Wi-Fi and mobile data, lose connectivity during an upload or regain access while the application is in the background.
A reliable implementation should account for:
- Network availability.
- Request timeouts.
- Interrupted uploads.
- Background execution restrictions.
- Battery consumption.
- Duplicate requests.
- Application process termination.
Background work should be scheduled according to platform capabilities and user expectations.
On Android, WorkManager is commonly used for deferrable, persistent background work.
On iOS, background execution should be designed around the system's permitted background task mechanisms rather than assuming unrestricted execution.
Neither platform guarantees that background work will run immediately.
6. Make Operations Idempotent
A particularly important consideration is duplicate processing.
Suppose an application sends an order request but loses connectivity before receiving the response.
The user retries, and the application sends the same request again.
Without appropriate safeguards, the backend might process the operation twice.
Idempotency keys can help prevent this.
A client generates a unique identifier for a logical operation and includes it in the request. The backend recognises repeated submissions with the same identifier and avoids processing the same operation more than once.
This is especially important for payments, orders and other operations with financial or business consequences.
7. Test More Than Airplane Mode
Offline testing should cover a variety of real-world scenarios.
Consider testing:
- Initial application launch without connectivity.
- Existing cached data.
- New records created offline.
- Interrupted synchronisation.
- Duplicate request submission.
- Conflicting updates.
- Expired authentication.
- Application termination with pending operations.
- Network changes during an upload.
- Low storage conditions.
It is also important to test what happens when the application cannot retrieve a record locally.
An offline-first design should communicate the limitations of available data rather than presenting outdated information as current.
8. Choose Architecture Based on Data and Product Requirements
Not every application needs a sophisticated synchronisation engine.
A content reader may only require local caching and refresh behaviour.
A field-service application may need queued updates and conflict resolution.
A collaborative application may require more advanced consistency and synchronisation mechanisms.
The architecture should reflect the consequences of data loss, duplication and stale information.
Offline-first development is ultimately about making deliberate decisions regarding data ownership, consistency and user experience.
A successful implementation does not merely keep an application open without the internet. It ensures that users can continue performing meaningful operations and that their changes are reconciled safely when connectivity returns.

Top comments (0)