Mobile offline-first development is an architectural approach where local data storage and offline functionality take priority over network connectivity, ensuring apps remain fully functional regardless of internet availability. This paradigm has become critical as mobile users increasingly expect seamless experiences across spotty networks, airplane mode, and areas with poor connectivity. The key insight: apps should sync with servers only when beneficial, not when required — treating the network as an enhancement rather than a dependency, which fundamentally changes how you architect data flow, state management, and user interactions.
What This Cheat Sheet Covers
This topic spans 14 focused tables and 102 indexed concepts, 103 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Local Database Solutions
The local database is the heart of any offline-first app — it becomes the single source of truth the UI reads from, with the network merely topping it up. The right pick depends on your platform and data shape: relational stores like SQLite, Room, and Core Data give you ACID transactions and queryable schemas, while NoSQL options like Realm, Hive, and Isar trade some structure for raw speed and a simpler object model. SQLCipher sits alongside them as the encryption layer when the data at rest is sensitive.
| Database | Example | Description | |
|---|---|---|---|
sqlite3_open("app.db", &db);sqlite3_exec(db, "CREATE TABLE...", 0, 0, 0); | • Embedded relational database with zero-configuration file-based storage • industry standard for mobile apps with ACID transactions and cross-platform support (Android, iOS, desktop). | ||
data class User(…) interface UserDao { } abstract class AppDatabase : RoomDatabase() | • Android's SQLite abstraction layer with compile-time query verification, LiveData/Flow integration, and built-in migration support • serves as single source of truth in offline-first architecture | ||
let entity = NSEntityDescription.entity(…)let newUser = NSManagedObject(entity: entity, …)try context.save() | • Apple's object graph and persistence framework with automated change tracking, undo/redo support, and iCloud synchronization • uses SQLite as default backing store | ||
class User: Object { @Persisted var name: String }let realm = try! Realm()try! realm.write { realm.add(user) } | • Mobile-first NoSQL database with zero-copy architecture for instant reads, automatic object-relational mapping, and built-in encryption • supports iOS, Android, React Native with live objects that update automatically | ||
var box = await Hive.openBox('users');box.put('key', User(name: 'John'));var user = box.get('key'); | • Lightweight, pure Dart NoSQL database with blazing fast performance (no native dependencies) • uses binary format with lazy loading and supports custom type adapters for complex objects | ||
final isar = await Isar.open([UserSchema]);await isar.writeTxn(() async { await isar.users.put(user); }); | • High-performance Flutter database with ACID transactions, multi-isolate support, and full-text search • up to 10x faster than Hive with composite indexes and query optimization | ||
const users = database.collections.get('users');await database.write(async () => { await users.create(user => { user.name = 'John' }); }); | • Reactive offline-first database built on SQLite with lazy loading, multi-threaded performance, and automatic sync • optimized for complex React Native apps with thousands of records | ||
const request = indexedDB.open('AppDB', 1);const store = db.transaction('users', 'readwrite').objectStore('users');store.add({ id: 1, name: 'John' }); | • Browser-native asynchronous NoSQL database with indexes, transactions, and version management • storage limits vary (Chrome: ~60% disk, Safari mobile: ~50MB) with quota management required | ||
const db = new PouchDB('todos');await db.put({ _id: 'todo1', text: 'Buy milk' });db.sync('http://server/todos'); | • JavaScript database inspired by CouchDB with automatic sync to remote servers • uses IndexedDB in browsers, SQLite in Node.js, and handles conflict resolution via revision trees | ||
sqlite3_key(db, "passphrase", 10); | • 256-bit AES encryption extension for SQLite providing transparent full-database encryption • protects sensitive data at rest with minimal performance overhead (5-15% slower than plain SQLite). |