Hey there, fellow digital survivors! 👋
I'm that developer who once tried sending a "I love mom " message to mother on mothers day... while flying 30,000 feet above the Atlantic in airplane mode. The message showed up instantly on my screen like a confident liar. Two hours later, when wheels touched the ground, it actually flew.
Welcome to the chaotic, beautiful world of offline-first messaging — where WhatsApp acts like that overly optimistic Expo CLI dev who keeps building even when the bundler is screaming. This blog belongs to my mother, and when you are traveling and want to message family ,the offline messaging comes into the pitchure.
Let's implement the flying dream and implement it now, hard work.
The Airplane Mode Tragedy (That Actually Works)
Picture this:
You’re in a metro tunnel (classic Agra-Delhi route vibes), no bars, full airplane mode. You type:
"Bhai, paani ki tanki khali ho gayi hai, emergency!"
You hit send.
Boom. Blue ticks? No. But the message appears in the chat instantly. Your friend’s reply (which they sent 5 minutes ago) also magically shows up later.
How? Because WhatsApp isn’t a naive lover waiting for internet. It’s a professional offline-first hero.
1. Why Messaging Apps Need Offline Support (The "Real World Sucks" Reason)
Internet is like Mumbai local trains — unreliable, crowded, and disappears when you need it most.
- You go to villages with 2G (if lucky)
- Elevators, flights, basements, Jio/ airtel network in 2026 (still struggling)
- Your mom calls you during a power cut
Users expect apps to work like real life conversations — you speak even if the other person is in the bathroom. Apps that don’t support offline feel like cheap Chinese earphones — one sneeze and connection gone.
2. What Happens When You Send a Message Without Internet?
Your phone becomes a drama queen with commitment issues.
When you hit send:
- WhatsApp says "Cool story bro" and immediately shows the message in your chat.
- It doesn’t even try to send it to the server yet.
- It marks it internally as "pending" with a single gray tick (the "I’m trying my best" tick).
It’s like ordering food on Zomato during a blackout — the order is placed in the app, but Swiggy’s kitchen doesn’t know yet.
3. Local Storage & Message Persistence (The "SQLite is my Therapist" Moment)
This is where Expo devs start nodding aggressively.
WhatsApp (built on React Native, just like your Expo projects) uses local databases (SQLite under the hood or similar encrypted storage):
- Every message you type is saved locally first.
- Your entire chat history lives on your phone.
- Even if you restart the app 50 times, messages don’t disappear.
It’s like writing your resignation letter in Google Docs offline. The document exists. The boss just doesn’t know he’s fired yet.
4. Message Queueing on the Device (The Pending Action Gang)
WhatsApp maintains a local queue of actions:
- Send Message A
- Send Message B
- Upload photo of your dog wearing sunglasses
This queue is like that list of tasks you write on Sunday night but only complete on Friday.
Every pending message sits in this queue with metadata:
- Timestamp
- Message ID (UUID — very important)
- Recipient
- Retry count (because networks are chaotic)
5. Syncing Messages When Connectivity Returns (The Grand Reconciliation)
The moment internet comes back (Jio ka "Network Not Available" disappears):
WhatsApp goes into "I have places to be" mode:
- Fires all queued messages to the server
- Pulls any messages that arrived while you were offline
- Does a beautiful dance of eventual consistency
This is the part where Expo CLI would say expo publish after 47 failed builds.
6. Delivery States: The Emotional Journey
| State | Visual | Meaning | Vibe |
|---|---|---|---|
| Sent | One gray tick | "I said it" | Hopeful |
| Delivered | Two gray ticks | "Server received it" | Relieved |
| Read | Two blue ticks | "They saw it and chose silence" | Existential crisis |
These states are updated asynchronously. Your phone keeps polling or uses push notifications to update the UI.
7. Handling Media Uploads While Offline (The Real Boss Level)
Sending a 17MB video in airplane mode?
WhatsApp:
- Stores the media locally
- Shows it in chat with "Pending" overlay
- Queues the upload
- When online, uploads in background (with progress)
It’s like preparing a PowerPoint presentation offline and uploading it when your boss is in a good mood.
8. Conflict Resolution & Message Ordering (When Two People Text at Once)
This is where system design gets spicy.
WhatsApp uses:
- Timestamps (device time + server time reconciliation)
- Unique Message IDs
- Vector clocks or logical clocks (in more advanced setups)
If two messages cross each other while offline, the server decides order based on arrival time.
Sometimes it feels random. Like Indian traffic — no rules, only vibes.
9. Reliability vs Real-time Delivery Tradeoffs
Offline-first philosophy says:
"Better to show something immediately and fix it later than to show nothing."
This is why you sometimes see messages appear, then suddenly reorder when sync happens. Rare, but possible.
Eventual Consistency in simple words:
"Everything will be fine... eventually. Chill."
10. How Offline-First Architecture Improves Usability
Because of this architecture:
- You never lose a message (unless you delete the app)
- Feels instant even on terrible networks
- Works in villages, flights, and during bandhs
- Battery efficient (doesn’t hammer server when offline)
It’s the reason your mom can forward 47 "Good Morning" messages even when her network is worse than her jokes.
The Grand Architecture (For My Fellow Expo CLI Warriors)
mermaid
graph TD
A[User Types Message] --> B[Local Storage]
B --> C[Message Queue]
C --> D[UI Shows Instantly]
D --> E[Internet Returns]
E --> F[Sync Engine]
F --> G[Server]
G --> H[Delivery Receipts]
Top comments (0)