DEV Community

X.T.O
X.T.O

Posted on

I Built a Chat App With No Server (Just WebRTC)

I Built a Serverless P2P Chat That Runs Directly in Your Browser

Most chat applications work like this:

User A β†’ Server β†’ User B 
Enter fullscreen mode Exit fullscreen mode

Every message goes through a server.

This works well, but it also means:

Messages pass through a central server

The server must handle all traffic

It requires backend infrastructure

So I wanted to try something different.

I built a peer-to-peer chat tool that runs entirely in the browser.

No accounts.
No installation.
No chat server.

Just open the page and start chatting.

Try it here:

πŸ‘‰ https://xto.icu/tools/p2p-chat/


The Idea

Instead of sending messages through a server, the browsers connect directly to each other.

Browser A  ←→  WebRTC  ←→  Browser B
Enter fullscreen mode Exit fullscreen mode

Once the connection is established, messages travel directly between the two users.

No message storage.
No central chat server.

This is possible thanks to WebRTC, a browser technology designed for real-time communication.

WebRTC allows browsers to exchange data directly using RTCDataChannel, which supports low-latency peer-to-peer communication.


How It Works

The process is simple:

  1. User A opens the chat tool

  2. A session code is generated

  3. User B enters the same session code

  4. The browsers establish a WebRTC connection

  5. Messages flow directly between the two browsers

User A
   β”‚
   β”‚ session code
   β–Ό
User B
   β”‚
   β–Ό
WebRTC connection
   β”‚
   β–Ό
Direct chat
Enter fullscreen mode Exit fullscreen mode

Once connected, the chat behaves like a normal messaging app.

But under the hood, it's completely peer-to-peer.


Features

Current features of the tool:

πŸ’¬ Real-time chat

πŸ”— Peer-to-peer connection

πŸ”’ Encrypted WebRTC communication

🌐 Runs entirely in the browser

πŸ†“ Free to use

There is no signup and no installation required.

Just open the page and connect.


Why I Built This

I enjoy experimenting with what modern browsers can do.

Many developers still think browsers are only for displaying web pages.

But today browsers can do much more:

Real-time communication

Peer-to-peer networking

File transfers

Collaborative apps

All without installing anything.

Just open a webpage.


Possible Use Cases

Some interesting ways this tool can be used:

Quick private chats

Temporary communication

Testing WebRTC connections

Developer experiments

Learning about peer-to-peer networking


Try It Yourself

Open the tool on two devices or two browser tabs:

πŸ‘‰ https://xto.icu/tools/p2p-chat/

Share the session code and start chatting.

That's it.


What's Next

I'm currently experimenting with more browser-based P2P tools, such as:

P2P file transfer

P2P clipboard sharing

P2P streaming

More WebRTC experiments

Modern browsers are more powerful than many developers realize.


If you try the tool, I’d love to hear your feedback.

What features should I add next?

Top comments (2)

Collapse
 
htho profile image
Hauke T.

The interest part is the Signaling Server.
How did you implement it?

I wrote a simple Signaling Server in PHP because I have this dumb Webspace and don't need a cloud subscription or anything to run it:
github.com/htho/php-webrtc-signali...

Collapse
 
n2xto profile image
X.T.O

Good question!

The connection uses WebRTC with Cloudflare's public STUN server (stun:stun.cloudflare.com:3478) for NAT traversal.

The signaling mechanism is intentionally lightweight and only exchanges the SDP offer/answer and ICE candidates required to establish the connection.

Once the peer connection is established, all chat messages are sent directly peer-to-peer via WebRTC data channels.