Modern users increasingly demand privacy‑first communication tools that disappear as soon as the conversation ends. Building such an app challenges traditional architectures that rely on persistent databases and user accounts.
Ephemeral end‑to‑end encrypted chat is defined as a real‑time messaging and calling experience where messages are encrypted on the client, never stored on a server, and the session vanishes when participants leave.
How Ephemeral Chat Works
When a user opens the app, they generate a random 8‑character room code (e.g., K7M2‑9XQ4) and share it with peers. All participants who enter the same code join a shared room that can host up to 10 people (source: AnonChat implementation). The client creates an ECC key pair, exchanges public keys via a WebSocket, and derives a symmetric session key for encrypting all messages.
Cloudflare Durable Objects as Room Controllers
Each chat room maps to a single Durable Object that orchestrates WebSocket connections, validates room codes, and enforces the participant limit. The object lives only as long as there are active connections, automatically cleaning up when the last user disconnects. This pattern is highlighted in the Cloudflare Workers tutorial (Jan 29 2026) which shows how a Durable Object can control each chat room without any external database.
Client‑Side Encryption with Web Crypto
The Web Crypto API generates an elliptic‑curve key pair in the browser. Public keys are exchanged through the Durable Object, while the private keys never leave the client device. After a Diffie‑Hellman exchange, both sides derive a shared secret used to encrypt messages with AES‑GCM. Because encryption happens entirely on the client, the server only sees opaque ciphertext.
Real‑Time Voice Calls via WebRTC
For audio, the app leverages WebRTC DataChannels for signaling and peer‑to‑peer media streams. The Cloudflare Worker acts as a lightweight signaling server, forwarding SDP offers and ICE candidates between peers. Once the WebRTC connection is established, media flows directly between browsers, ensuring zero‑latency, end‑to‑end encrypted voice calls.
Serverless Deployment and Scaling
Deploying the entire stack—static assets, WebSocket gateway, and Durable Objects—requires only a single command to Cloudflare Workers. The platform automatically scales to handle spikes, while the pay‑as‑you‑go model keeps costs low because you are billed only for active connections, not for idle storage.
Frequently Asked Questions
Is any data ever stored on the server?
No. All messages and media are encrypted on the client and transmitted peer‑to‑peer. The server only routes encrypted payloads and does not persist them.
Can I integrate this architecture with existing back‑ends?
Yes. The Durable Object API is HTTP‑compatible, so you can add authentication or analytics layers without changing the core chat logic.
What browsers support the required APIs?
Modern browsers (Chrome, Edge, Firefox, Safari) fully support Web Crypto, WebRTC, and the Fetch/WebSocket APIs used in this solution.
How does the app enforce the 10‑person limit?
The Durable Object tracks active connections and rejects new join requests once the limit is reached, as described in the AnonChat source code.
Is the solution cost‑effective for large user bases?
Because you pay only for compute time and active connections, the model scales economically even for high‑traffic scenarios.
Neptune Infotech can help you design and launch privacy‑focused, serverless communication platforms that scale globally.