How to Build a Chat App Like WhatsApp
November 18, 2026 · 12 min read

Building an app like WhatsApp looks simple from the outside: send a message, see it arrive. Underneath, a chat app has to keep millions of connections open, deliver messages in order to people who go offline mid-conversation, encrypt everything end to end, sync across devices, carry voice and video calls and fight spam, all on unreliable mobile networks. WhatsApp itself has more than three billion monthly users, which shows both the size of the opportunity and the standard users expect.
This guide explains how a WhatsApp-style messenger works, which features to build first, how real-time delivery and read receipts work (with a working Node.js example), how end-to-end encryption, group chats and calls are built, what the tech stack looks like and what it costs.
How a Chat App Works
A modern messaging app has a handful of core parts:
- Mobile and desktop clients that store conversations locally, so chats open instantly and work offline.
- A connection gateway that keeps a persistent connection to every online device, usually over WebSockets or a similar protocol; our comparison of WebSockets and server-sent events explains the options.
- A message service that routes each message to the right devices, queues it for offline users and tracks its status.
- Storage for undelivered messages, user accounts, contacts and group membership, plus object storage for photos, videos and voice notes.
- Push notifications to wake up devices that are not connected.
- Calling infrastructure for voice and video, built on WebRTC.
With end-to-end encryption, the server never sees message content. It only moves encrypted envelopes between devices, which also reduces what you must protect and store.
Core Features
| MVP | Later versions |
|---|---|
| Sign-up with phone number or email verification | Passkeys, multi-device linking and desktop apps |
| One-to-one chats with sent, delivered and read status | Message editing, reactions, replies and disappearing messages |
| Group chats with admins | Communities, channels and broadcast lists |
| Photos, videos, documents and voice notes | Status updates, stickers and GIF search |
| Push notifications and typing indicators | Voice and video calls, group calls and screen sharing |
| Block, report and basic moderation tools | Payments, business accounts, bots and AI assistants |
Start with reliable text messaging, groups, media and notifications. Calls and encryption are essential for a general messenger, but a niche product, such as a workplace or community chat, can sometimes launch without calls.
Real-Time Messaging and Read Receipts
WhatsApp's familiar ticks map to three moments: one tick when the server has the message, two ticks when it reaches the recipient's device, and two blue ticks when the recipient opens it. This example uses the ws library for the server and Node.js's built-in WebSocket client to simulate two users, with Ben offline when Amina sends her message:
// chat-ticks.mjs - one-to-one chat with WhatsApp-style ticks: sent, delivered, read (ws server, Node 22+ WebSocket client)
import { WebSocketServer } from "ws";
const online = new Map(); // user id -> open socket
const pending = new Map(); // user id -> messages waiting while that user is offline
const send = (socket, payload) => socket.send(JSON.stringify(payload));
function deliver(msg) {
send(online.get(msg.to), { type: "message", id: msg.id, from: msg.from, text: msg.text });
const sender = online.get(msg.from);
if (sender) send(sender, { type: "status", id: msg.id, status: "delivered" }); // two grey ticks
}
const wss = new WebSocketServer({ port: 0 });
wss.on("connection", (socket, req) => {
const user = new URL(req.url, "http://localhost").searchParams.get("user"); // use a verified token in production
online.set(user, socket);
for (const msg of pending.get(user) ?? []) deliver(msg); // flush messages that arrived while offline
pending.delete(user);
socket.on("message", (raw) => {
const event = JSON.parse(raw);
if (event.type === "message") {
const msg = { id: event.id, to: event.to, text: event.text, from: user };
send(socket, { type: "status", id: msg.id, status: "sent" }); // one grey tick: the server has it
if (online.has(msg.to)) deliver(msg);
else pending.set(msg.to, [...(pending.get(msg.to) ?? []), msg]); // and send a push notification here
}
if (event.type === "read" && online.has(event.from)) {
send(online.get(event.from), { type: "status", id: event.id, status: "read" }); // two blue ticks
}
});
socket.on("close", () => online.delete(user));
});
wss.on("listening", async () => {
const connect = (user, onEvent) => new Promise((resolve) => {
const ws = new WebSocket(`ws://localhost:${wss.address().port}/?user=${user}`);
ws.onmessage = ({ data }) => onEvent(JSON.parse(data), ws);
ws.onopen = () => resolve(ws);
});
const amina = await connect("amina", (event) => {
console.log(`Amina sees: ${event.id} ${event.status}`);
if (event.status === "read") { amina.close(); ben.close(); wss.close(); }
});
amina.send(JSON.stringify({ type: "message", id: "m1", to: "ben", text: "Are we still on for 7?" }));
await new Promise((resolve) => setTimeout(resolve, 100)); // Ben is offline for a moment
const ben = await connect("ben", (event, ws) => {
console.log(`Ben receives: ${event.text}`);
ws.send(JSON.stringify({ type: "read", id: event.id, from: event.from }));
});
});
Amina sees "sent" straight away. Ben is offline, so the server queues the message; when he connects, it is delivered, Amina's status changes to "delivered", and when Ben's app reports that he has read it, Amina sees "read". In production you would authenticate each connection with a verified token, store queued messages in a database rather than memory, send a push notification to offline users and let each device acknowledge receipt so nothing is lost when a connection drops mid-delivery.
Every message also needs a unique ID created on the sending device. That lets the app retry safely after a network failure, lets the server ignore duplicates and lets each device order messages consistently.
End-to-End Encryption
Users now expect end-to-end encryption, where only the people in a conversation can read it. WhatsApp uses the Signal Protocol, which combines key agreement with a "double ratchet" so that every message uses a new key: a stolen key cannot unlock earlier messages, and the conversation recovers its security as it continues. The Signal Protocol documentation describes the design, and Signal publishes its implementation as an open-source library; check its licence terms before using it in a commercial product.
For groups, the IETF's Messaging Layer Security (MLS) standard, RFC 9420 was designed to encrypt efficiently for groups of thousands. It is gaining adoption fast: in May 2026, Apple and Google began rolling out end-to-end encrypted RCS messaging between iPhone and Android, initially in beta, using MLS through the GSMA's RCS Universal Profile 3.0, as Google also explains.
The golden rule is never to design your own cryptography. Use a proven protocol and library, store private keys only on devices, let users verify each other's security codes and have the implementation reviewed by security specialists. Our guide to mobile app security best practices covers the rest of the app.
Group Chats
Groups multiply every problem. A message to a 500-person group must reach 500 people's devices, each with its own delivery and read status, and with encryption every member's device needs the right keys. Common approaches include fanning out one encrypted copy per device on the server, using sender keys so each message is encrypted once for the group, or using MLS. Add roles such as admins, invite links, member limits and moderation, and store group membership as carefully as payments, because a bug there can leak conversations.
Voice and Video Calls
Calls run on WebRTC, the open standard for real-time audio and video. A signalling service, which can reuse your WebSocket connection, sets the call up. STUN servers help devices find a direct path to each other, and TURN servers relay traffic when firewalls block a direct path, which happens often on mobile and corporate networks. Group calls usually go through a selective forwarding unit (SFU), a server that receives each participant's stream once and forwards it to everyone else.
Budget for relay bandwidth, which grows with call minutes, and test on poor networks, because call quality is what users notice most. On iOS, integrate with CallKit, and on Android with the Telecom framework, so incoming calls ring like normal phone calls.
Media, Offline Sync and Notifications
Photos and videos should upload directly from the app to object storage, encrypted on the device when the chat is end-to-end encrypted, with only a link and key sent in the message. Generate thumbnails, compress video before upload and let users choose whether media downloads automatically on mobile data.
Chat apps must work on bad connections. Store conversations in a local database, show messages immediately with a pending state, queue outgoing messages and sync when the connection returns; our guide to offline-first apps explains the patterns. When the app is closed, push notifications through APNs and Firebase Cloud Messaging tell the user about new messages; for encrypted apps, the notification often wakes the app to fetch and decrypt the message itself. Our push notification best practices cover timing and grouping.
Scaling to Millions of Users
- Connection servers hold open sockets and scale horizontally behind a load balancer. A registry, often Redis, records which server each user is connected to.
- A message bus such as Kafka or NATS moves messages between servers reliably.
- Databases partition messages and inbox state by user or conversation; Cassandra-style stores, PostgreSQL with partitioning and similar options all work at different scales.
- Presence and typing indicators are high-volume and short-lived, so keep them in memory and never in your main database.
- Language choice: WhatsApp famously used Erlang, and Elixir, Go and Node.js are all common for connection-heavy services.
You do not need this on day one. A single well-built service handles a surprising number of users; split into services when load demands it, as our guide to microservices vs monoliths explains.
Safety, Spam and Regulation
Messaging apps attract spam, scams and abuse. Verify phone numbers or emails, rate-limit new accounts, let users block and report, show warnings for messages from unknown contacts and detect mass messaging. With encryption you cannot scan content on the server, so rely on reports, metadata signals and on-device protections.
Regulation is changing the market too. Under the EU's Digital Markets Act, WhatsApp began enabling third-party chats in Europe in November 2025, starting with BirdyChat and Haiket, with users choosing whether to opt in. Most new apps will not be designated gatekeepers, but interoperability is becoming a realistic way to reach users of the big platforms. Follow privacy law for phone numbers and contact lists, and publish clear data policies; see our guide to data privacy laws for developers.
Build From Scratch or Use a Chat SDK?
Hosted chat platforms and SDKs, such as Stream, Sendbird and CometChat, or a back end like Firebase, can get messaging into an app in weeks. They suit apps where chat is a feature, such as buyer-seller messaging in a marketplace like the one in our Airbnb guide or matches chatting in a dating app. Per-user pricing can become expensive at scale, and you depend on the provider's encryption and data policies.
Build your own when messaging is the product, when you need full control of encryption and data, or when you expect a large user base. Many teams start with an SDK and move to their own back end once usage proves the product.
Recommended Tech Stack
- Clients: Flutter or React Native for cross-platform apps, or Swift and Kotlin for native apps, with SQLite-based local storage.
- Back end: Node.js, Go or Elixir for connection servers; see our Node.js REST API guide for the API side.
- Real time: WebSockets via ws or Socket.IO, Redis for presence and routing, and Kafka or NATS as scale grows.
- Storage: PostgreSQL or Cassandra-style databases, plus object storage and a CDN for media.
- Calls: WebRTC with TURN servers and an SFU.
- Security: Signal Protocol or MLS libraries, passkeys and device verification.
Video features such as long video messages or live streams draw on the same techniques as a streaming service; see our guide to building an app like Netflix. Messaging is also the core of most super apps, which build payments and services around chat. If you want an AI assistant inside WhatsApp itself instead of a new app, read our guide to building a WhatsApp AI chatbot.
How Much Does an App Like WhatsApp Cost?
| Scope | What you get | Estimated cost | Timeline |
|---|---|---|---|
| MVP | Cross-platform apps, one-to-one and group chat, media, receipts, push, basic moderation | $40,000 to $90,000 | 3 to 5 months |
| Full messenger | End-to-end encryption, voice and video calls, multi-device, web or desktop app, admin tools | $100,000 to $200,000 | 6 to 9 months |
| Large-scale platform | Multi-region infrastructure, channels and communities, payments, bots and AI features | $250,000+ | 12 months or more |
These are typical 2026 agency estimates. Running costs include servers, TURN bandwidth for calls, media storage and SMS verification codes, which can be a significant cost in some countries. Our guide to mobile app development costs explains what drives the numbers.
Frequently Asked Questions
How much does it cost to build an app like WhatsApp?
A focused MVP typically costs $40,000 to $90,000. A full messenger with end-to-end encryption, calls and multi-device support usually costs $100,000 to $200,000 or more. These are estimates that depend on scope and team location.
Which protocol is best for a chat app?
WebSockets are the most common choice for real-time messaging in apps. Some messengers use custom binary protocols or MQTT for efficiency, and WebRTC handles voice and video calls.
How does WhatsApp encryption work?
WhatsApp uses the Signal Protocol, which creates new encryption keys for every message, so only the devices in a conversation can read it and a stolen key cannot unlock other messages.
Can I build a chat app with Firebase?
Yes. Firebase can handle real-time messages, authentication, storage and notifications for an MVP. At large scale, or when you need full control of encryption, a custom back end is usually cheaper and more flexible.
How do read receipts work?
The server confirms when it receives a message, the recipient's device confirms when the message arrives, and the app sends a read event when the user opens the chat. Each event updates the status the sender sees.
How long does it take to build a chat app?
An MVP usually takes three to five months. Adding encryption, calls and multi-device support typically brings a full messenger to six to nine months.
Build Your Messaging App
We build secure, real-time chat apps and in-app messaging, from MVP to scale, with encryption, calls and notifications done properly. Contact our team to discuss your messaging product.