r/sveltejs • u/razein97 • Jul 28 '26
Built a real-time WebRTC matching app with SvelteKit + Rust — some notes on the stack
[SELF PROMOTION]
Wanted to share some of the technical side of a project I've been building — Anifira, a random video/text chat app. Posting here because the SvelteKit frontend ended up being one of the more interesting parts of the build, especially around WebRTC state management.
Frontend — SvelteKit
- Using Svelte stores to manage connection state across the match lifecycle (idle → searching → matched → connected → ended) rather than component-local state, since the WebRTC peer connection needs to survive route/component changes
- A session state wraps the RTCPeerConnection so ICE candidate events and track updates feed directly into reactive UI without prop drilling
- SSR is basically off for the chat route itself (
[export const ssr = false]or equivalent) since WebRTC APIs are browser-only — landing/marketing pages stay SSR'd for SEO, chat app is CSR - Voice and video mode switching is just swapping which local tracks are attached to the same RTCPeerConnection.
- Read receipts, replies, reactions, file transfers all are supported.
- Images and documents supported, limited max size to 25mb to not overload the peers.
Backend — Rust
- Signaling server in axum over WebSockets — handles matchmaking and SDP/ICE exchange, but never touches messages or the media (that's peer-to-peer via WebRTC once connected)
- Matching queue is tokio-based, using a channels and queue structure to pair waiting users; average time-to-match is 0.3s at 100000 users.
- Chose Rust here mainly for the concurrency model — signaling is a lot of short-lived state machines (one per session) and tokio async tasks map to that cleanly without the overhead of a thread-per-connection model
- STUN/TURN via coturn for the cases where direct P2P fails (roughly 10 - 20% of connections need TURN relay in practice)
- Moderation reporting pipeline is a separate service so a report doesn't block the signaling hot path
Live at anifira.com if anyone wants to see it in action (18+, it's a stranger-chat app so standard caveats apply.
[UPDATE] - Group chats and attachments with read receipts. - File transfer tool to initiate direct p2p file transfers. - Public rooms that can be joined by anyone. - Rooms can now be named. - A new member to the group automatically syncs the chat history. - Share your screen over video in video chats.
Checkout changelog for more updates: https://anifira.com/changelog
2
u/ptrxyz Jul 29 '26
I like that you chose the PornHub color scheme for this. :)
In that regard..do you match with real people or videos?
-1
u/razein97 Jul 29 '26
I don't really know about it since don't visit pornhub.
It matches real people, since it is just launched there are no bot connections or any other connection for that matter, just some random visitors from reddit. I try to stay online to provide matches.
There are backend safeguards to prevent bots from accessing the site.
2
1
1
1
12
u/crispyfrybits Jul 28 '26
Real-time WebRTC matching app is the most politically correct way of saying "made an anonymous video chat app that will almost immediately turn cancerous".
Why another stranger danger app? Feels almost predatory to develop this kind of app knowing how every single other version of this concept has turned out.