Omegle for developers. Sign in, get matched with a random developer, and talk over peer-to-peer video or text.
There is no signaling server. Firestore is the signaling layer:
rooms/{roomId}
status: waiting | connecting
mode: video | text
pairId # identifies the current pairing
createdBy / joinedBy
offer / answer # tagged with the pairId they belong to
createdAt / updatedAt
creatorLastSeen / joinerLastSeen
rooms/{roomId}/candidates/{candidateId}
candidate / from / createdAt
- The creator opens a
waitingroom for its mode and writes its profile. - A joiner finds an open room of the same mode and claims it inside a
Firestore transaction, so two strangers can never be paired with the same
person. The claim starts a new pairing: it writes a fresh
pairIdand drops any signaling left by the previous stranger. - The creator writes an SDP offer; the joiner writes the SDP answer; both write
ICE candidates to the room subcollection and apply the other side's. Offers
and answers carry the
pairId, so a stale description can never be applied. - Each peer refreshes a heartbeat every 5 seconds. A peer whose heartbeat stops advancing for 45 seconds is treated as gone and the room is reset or removed.
- A stranger that opens a room keeps looking for a few seconds: when two people start at the same time, the owner of the newer room id gives up its own room and joins the older one, so they still match.
pagehide/beforeunloadbest-effort cleanup plus a stale-room sweep on every search guarantee that closed tabs cannot leave phantom users behind.- Firestore does not cascade-delete subcollections, so room cleanup explicitly removes the candidate documents as well.
- When a direct path between two peers is impossible, media falls back to a
TURN relay. The Cloudflare TURN key never reaches the browser:
api/turn.jsmints short-lived credentials for it.
WebRTC media and the in-call text channel never touch Firestore: the text chat
rides on an RTCDataChannel.
- Random one-to-one matching for video or text chat, never across modes
- Atomic room claiming (no double matches) that also converges simultaneous searches
- Microphone and camera toggles, reflected on the other side
- End Chat and Next Person
- In-call text chat over a WebRTC data channel
- Text-only mode from the lobby
- Heartbeat-based disconnect detection, negotiation timeouts and full room/candidate cleanup
cd client
bun install
cp .env.example .env # fill in the Firebase web app values
bun run devThe client validates its environment at startup (src/lib/env.ts): a missing
Firebase value stops the app with a clear message instead of booting a client
that cannot reach Firestore. With VITE_USE_EMULATOR=true the Firebase values
may stay empty, because the demo project defaults are filled in.
The buttons use signInWithPopup, which works even when the browser blocks
third-party storage. If the browser refuses to open a popup at all, the app
falls back to signInWithRedirect.
Redirect only works when Firebase's OAuth helper (/__/auth/*) is served from
the app's own origin. Both environments can do that — vite.config.ts proxies
it in development and vercel.json rewrites it in production — but it is
opt-in: point VITE_AUTH_DOMAIN at the app host instead of the
*.firebaseapp.com one, and add that host under Firebase → Authentication →
Settings → Authorised domains.
Note that Google blocks OAuth in automated browsers, so a headless browser cannot complete a Google sign-in regardless of the flow; use the emulator's guest login for automated runs.
client/api/turn.js exchanges the Cloudflare TURN key for short-lived
credentials. Set these in the host environment (for example the Vercel project
settings) and never behind a VITE_ prefix:
CLOUDFLARE_TURN_KEY_ID=...
CLOUDFLARE_TURN_API_TOKEN=...
Without them the endpoint answers 503 and the app quietly uses STUN only,
which is what happens in local development because Vite does not serve api/.
The app can run fully offline against the Firebase emulator suite:
bun install # root tooling: firebase-tools, vitest, Playwright
bunx playwright install chromium
cp client/.env.example client/.env
# set VITE_USE_EMULATOR=true in client/.env
bun run emulatorsWith the emulator enabled, the login page also exposes an anonymous "Continue as Guest" button.
bun run test:rules # Firestore security rules against the emulator
bun run test:e2e # two browser tabs matching over Firestore + WebRTCThe end-to-end suite covers matching, chat, media toggles, End Chat, Next Person, text-only mode, mode isolation, simultaneous searches, and disconnect cleanup.
Security rules live in firestore.rules and the emulator config in
firebase.json. They enforce:
- waiting rooms are discoverable; claimed rooms are visible to their two peers only
- only a peer in a room can read, publish or delete its ICE candidates, and only as itself (candidates expose IP addresses)
- each write path is restricted to the fields it is allowed to touch, so a claimer cannot rewrite the room owner or the signaling
- rooms carry no email addresses
Deploy them with:
firebase deploy --only firestore:rules,firestore:indexesThe matching query needs the composite index in firestore.indexes.json
(status + mode + creatorLastSeen), so deploy the indexes as well.
- Email: sahilverma.webdev@gmail.com
- Portfolio: sahilverma.dev
- GitHub: @sahilverma-dev
- Twitter: @sahilverma_dev
- LinkedIn: sahilverma-dev
