By Abdelrahman Saed — Senior Mobile Engineer. Last updated: 2026-08-10.
Offline-first is a mobile architecture pattern where the local database is the primary source of truth for the UI. Reads resolve instantly from the device, writes are persisted locally and replayed on reconnect, and the network's role is background reconciliation — not blocking the user interface.
In an offline-first app, every read goes to the local database first. The UI never waits on a network round-trip for data it already has. A background sync engine reconciles the local database with the server.
User opens app → reads from local DB (instant) → background sync updates DB
User writes → persisted locally (instant) → queued and replayed on reconnect
The data flow at iStoria (5M+ users) uses PowerSync for streaming sync and Drift for the typed local SQLite database:
class StoriesRepository {
StoriesRepository(this._remote, this._local);
final StoriesRemoteDataSource _remote;
final StoriesLocalDataSource _local; // reads from Drift
Future<Either<Failure, List<Story>>> fetchStories() async {
try {
final stories = await _local.cachedStories(); // instant local read
unawaited(_remote.refreshInBackground()); // sync, never blocks UI
return Right(stories);
} on CacheException catch (e) {
return Left(CacheFailure(e.message));
}
}
}
The key insight: the repository returns local data immediately and kicks off a background refresh it does NOT await. The UI gets instant data; PowerSync converges the local DB with the server asynchronously; the UI picks up changes reactively through Drift's stream.
Offline writes use a queue — a Dio interceptor backed by a local Hive box captures writes made while offline, returns an optimistic success so the UI keeps moving, and replays them automatically on reconnect:
Use offline-first when:
Don't use offline-first when:
Offline-first means the app works without a network — reads are cached, writes are queued. Local-first goes further: the local database IS the source of truth, and the server's role is to sync, not to serve. Every local-first app is offline-first, but not every offline-first app is local-first. See the offline-first vs local-first comparison for details.
Drift (typed SQLite with code generation) is the most popular choice for structured data. For key-value storage, Hive or Isar. For sync, PowerSync (which syncs Drift tables with a Postgres backend) or Supabase Realtime. At iStoria, we use PowerSync + Drift.
Available for hire. Abdelrahman Saed is a Senior Mobile Engineer (Flutter) — open to full-time, fractional, contract, or advisory work. Hire me →
Book a 20-minute call · Download the CV (PDF) · See how I work