Added additional TURN server endpoint for better connectivity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Rondevu Demo
🎯 Interactive WebRTC peer discovery and connection demo
Experience topic-based peer discovery and WebRTC connections using the Rondevu signaling platform.
Related repositories:
- rondevu-server - HTTP signaling server
- rondevu-client - TypeScript client library
Overview
This demo showcases the complete Rondevu workflow:
- Register - Get peer credentials (automatically saved)
- Create Offers - Advertise your WebRTC connection on topics
- Discover Peers - Find other peers by topic
- Connect - Establish direct P2P WebRTC connections
- Chat - Send messages over WebRTC data channels
Key Features
- Topic-Based Discovery - Find peers by shared topics (like torrent infohashes)
- Real P2P Connections - Actual WebRTC data channels (not simulated)
- Connection Manager - Uses high-level
RondevuConnectionAPI (no manual WebRTC plumbing) - Persistent Credentials - Saves authentication to localStorage
- Topics Browser - Browse all active topics and peer counts
- Multiple Connections - Support multiple simultaneous peer connections
- Real-time Chat - Direct peer-to-peer messaging
Quick Start
Installation
npm install
Development
npm run dev
This starts the Vite dev server at http://localhost:5173
Build for Production
npm run build
The built files will be in the dist/ directory.
Preview Production Build
npm run preview
How to Use
Step 1: Register (One-time)
The demo automatically registers you when you first visit. Your credentials are saved in localStorage for future visits.
Step 2: Create an Offer
- Go to the "Create Offer" tab
- Enter one or more topics (comma-separated), e.g.,
demo-room, testing - Click "Create Offer"
- Your offer is now advertised on those topics
Share the topic name with peers you want to connect with!
Step 3: Discover and Connect (Other Peer)
- Go to the "Discover Offers" tab
- Enter the same topic (e.g.,
demo-room) - Click "Discover Offers"
- See available peers and their offers
- Click "Answer Offer" to connect
Step 4: Chat
- Once connected, go to the "Chat" tab
- Select a connection from the dropdown
- Type messages and hit Enter or click Send
- Messages are sent directly peer-to-peer via WebRTC
Browse Topics
Click the "Topics" tab to:
- See all active topics
- View peer counts for each topic
- Quick-discover by clicking a topic
Testing Locally
The easiest way to test:
- Open the demo in two browser windows (or tabs)
- Window 1: Create an offer with topic
test-room - Window 2: Discover offers in
test-roomand answer - Switch to Chat tab in both windows
- Start chatting peer-to-peer!
Technical Implementation
Connection Manager
This demo uses the high-level RondevuConnection class which abstracts all WebRTC complexity:
// Create connection
const conn = client.createConnection();
// Set up event listeners
conn.on('connected', () => {
console.log('P2P connection established!');
});
conn.on('datachannel', (channel) => {
channel.onmessage = (event) => {
console.log('Message:', event.data);
};
});
// Create offer
await conn.createOffer({
topics: ['demo-room'],
ttl: 300000
});
// Or answer an offer
await conn.answer(offerId, offerSdp);
The connection manager handles:
- Offer/answer SDP generation
- ICE candidate gathering and exchange
- Automatic polling for answers and candidates
- Data channel lifecycle
- Connection state management
- Event-driven API
What Happens Under the Hood
-
Offerer calls
conn.createOffer():- Creates RTCPeerConnection
- Generates SDP offer
- Creates data channel
- Posts offer to Rondevu server
- Polls for answers every 2 seconds
-
Answerer calls
conn.answer():- Creates RTCPeerConnection
- Sets remote description (offer SDP)
- Generates SDP answer
- Posts answer to server
- Polls for ICE candidates every 1 second
-
ICE Exchange:
- Both peers generate ICE candidates
- Candidates are automatically sent to server
- Peers poll and receive remote candidates
- ICE establishes the direct P2P path
-
Connection Established:
- Data channel opens
- Chat messages flow directly between peers
- No server relay (true P2P!)
Architecture
- Frontend: React + Vite
- Signaling: Rondevu server (Cloudflare Workers + D1)
- Client: @xtr-dev/rondevu-client (TypeScript library)
- WebRTC: RTCPeerConnection with Google STUN servers
Server Configuration
This demo connects to: https://api.ronde.vu
To use a different server, modify API_URL in src/App.jsx:
const API_URL = 'https://your-server.com';
Deployment
Deploy to Cloudflare Pages
Quick Deploy via Wrangler:
npm run build
npx wrangler pages deploy dist --project-name=rondevu-demo
Or via Git Integration:
- Push to GitHub/GitLab
- Connect to Cloudflare Pages
- Set build command:
npm run build - Set output directory:
dist - Deploy automatically on every push!
Development Notes
- Credentials are stored in localStorage and persist across sessions
- Offers expire after 5 minutes by default
- The connection manager polls automatically (no manual polling needed)
- Multiple simultaneous connections are supported
- WebRTC uses Google's public STUN servers for NAT traversal
- Data channel messages are unreliable but fast (perfect for chat)
Technologies
- React - UI framework
- Vite - Build tool and dev server
- @xtr-dev/rondevu-client - Rondevu client library
- RTCPeerConnection - WebRTC connections
- RTCDataChannel - P2P messaging
License
MIT