When you start building a mobile app or web platform that needs real-time video calling — whether through a peerjs video call setup or a fully managed API — you face an immediate choice: pay for a managed API like Agora, Twilio, or Zegocloud — or build your own real-time communication layer using WebRTC. At Primocys, we deliver self-hosted WebRTC for both mobile apps (Flutter & React Native on iOS and Android) and web applications (React, Next.js, Vue) — same open standard, same cost advantage, same data ownership. This guide gives you the honest numbers, the architecture differences, and the decision framework we use when we build video calling into apps like Corex Messenger and Vemenne.
What Is WebRTC & How Does PeerJS Simplify It?
WebRTC (Web Real-Time Communication) is an open-source standard — built into every major browser and available natively on Android and iOS — that enables peer-to-peer audio, video, and data transmission directly between devices. It is the same technology underlying Google Meet, Facebook Messenger’s video calls, and Discord.
The challenge with raw WebRTC is complexity. You need to manage ICE (Interactive Connectivity Establishment) candidates, SDP (Session Description Protocol) negotiation, STUN servers (for NAT discovery), TURN servers (for relay when direct P2P fails), and your own signalling layer. It is powerful but verbose.
PeerJS is an open-source JavaScript library that wraps WebRTC’s complexity behind a clean API. Instead of managing ICE candidates and SDP offers yourself, PeerJS handles the handshake, NAT traversal, and connection setup — letting you focus on your application logic.
The key insight: Agora, Twilio, and Zegocloud are essentially “WebRTC-as-a-service” — they host the signalling servers, STUN/TURN infrastructure, and media relay on your behalf and charge per minute for the privilege. PeerJS gives you the same WebRTC standard but you host the infrastructure yourself, paying only for server costs instead of per-minute usage fees.
WebRTC for Mobile App vs Web — How Primocys Delivers Both
One of the most common misconceptions we hear: “WebRTC is for browsers only.” That hasn’t been true for years. At Primocys, we implement self-hosted WebRTC across every platform — and the same infrastructure (your TURN server + signalling server) powers all of them simultaneously.
Mobile App (Flutter & React Native)
WebRTC runs natively on both Android and iOS via official platform APIs. For Flutter projects (our primary mobile stack), we use the flutter_webrtc package — a mature, production-tested binding to the native WebRTC engine on both platforms. For React Native, the equivalent is react-native-webrtc. Both connect to the same PeerJS signalling server your web users use — one backend, all platforms.
- Flutter + flutter_webrtc — production-ready, used in Vemenne (iOS & Android)
- React Native + react-native-webrtc — compatible with the same signalling server
- Works on both Android (API 21+) and iOS (13+)
- Same TURN server handles NAT traversal for mobile and cellular users
- No Agora SDK, no proprietary binary — just WebRTC native APIs
Web Application (React, Next.js, Vue, Vanilla JS)
In web browsers, WebRTC is a first-class native API — available in Chrome, Firefox, Safari, and Edge without any plugin. PeerJS wraps the browser’s RTCPeerConnection API, meaning the exact same JavaScript calling code works across all major browsers. For React / Next.js projects, we integrate PeerJS into a custom hook or context so call state is managed cleanly alongside your application state.
- Native browser support — Chrome, Firefox, Safari, Edge (no plugins)
- Works in React, Next.js, Vue, Angular, and plain JavaScript
- Same PeerJS signalling server serves both mobile and web users
- Screen sharing, file transfer via Data Channel, and group calls all supported
The architecture advantage: Because WebRTC is an open standard implemented at the OS and browser level, a single backend deployment — one Node.js PeerJS signalling server + one Coturn TURN server — serves your Flutter mobile app, your iOS app, your Android app, and your web application simultaneously. You are not paying Agora per-minute for each platform separately.
How Each Platform Actually Works
ARCHITECTURE: SELF-HOSTED WEBRTC VS MANAGED API (AGORA / TWILIO / ZEGOCLOUD)
❌ Agora / Twilio / Zegocloud
The architecture difference is fundamental. With third-party APIs, all your call data flows through their infrastructure — every packet, every audio frame, every video frame. With self-hosted WebRTC, direct peer-to-peer connections handle approximately 80–85% of calls, and your own TURN server handles the remaining 15–20% where direct connection is blocked by NAT or firewalls. Your data never leaves your infrastructure.
Real 2026 Cost Breakdown — All Four Platforms
Let’s use a consistent scenario for fair comparison: 100 daily active users, each making an average of 60 minutes of HD video calls per day, 30 days per month. That’s 180,000 call-minutes per month.
| Scenario | Agora | Twilio | Zegocloud | PeerJS WebRTC (Self-Hosted) |
|---|---|---|---|---|
| Pricing model | Per minute/user | Per minute/user | Per minute/user | Fixed server cost |
| HD video rate | $8.99/1,000 min | $4.00/1,000 min | $0.99/1,000 min | $0 per minute |
| 10 users, 1hr/day | $16.18/mo | $7.20/mo | $1.78/mo | $15–$25/mo |
| 100 users, 1hr/day | $718.20/mo | $720.00/mo | $108.00/mo | $30–$45/mo |
| 1,000 users, 1hr/day | $7,182/mo | $7,200/mo | $1,080/mo | $80–$150/mo |
| 10,000 users, 1hr/day | $71,820/mo | $72,000/mo | $10,800/mo | $300–$600/mo |
| Data ownership | ❌ Their servers | ❌ Their servers | ❌ Their servers | ✅ Your servers |
| Vendor lock-in | ❌ High | ❌ High | ❌ High | ✅ None |
| Year-1 saving (vs Agora, 100 users) | — | Similar to Agora | $7,320 saving | ~$8,200 saving |
Important note on Zegocloud: Zegocloud appears significantly cheaper than Agora and Twilio — and for small-scale apps with 10–50 users, it can be cheaper than self-hosted WebRTC (which has a fixed baseline cost). However, at 1,000+ users, the per-minute model still results in $1,080/month vs $80–$150/month for self-hosted. Additionally, your data still routes through their servers — an issue for enterprise, healthcare, or compliance-sensitive applications.
Interactive Cost Calculator — See Your Numbers
Full Feature Comparison Table
| Feature | PeerJS WebRTC (Self-Hosted) | Agora | Twilio | Zegocloud |
|---|---|---|---|---|
| 1:1 Video Calls | ✅ | ✅ | ✅ | ✅ |
| Group Video Calls | ⚡ SFU needed | ✅ | ✅ | ✅ |
| Audio Calls | ✅ | ✅ | ✅ | ✅ |
| Screen Sharing | ✅ | ✅ | ✅ | ✅ |
| Data Channels (P2P file share) | ✅ | ❌ | ❌ | ❌ |
| Self-hosted option | ✅ Full | ❌ None | ❌ None | ⚡ Limited |
| Data stays on your server | ✅ | ❌ | ❌ | ❌ |
| GDPR / HIPAA / PDSK ready | ✅ Full control | ⚡ Partial | ⚡ Partial | ⚡ Partial |
| No vendor lock-in | ✅ | ❌ | ❌ | ❌ |
| Predictable monthly cost | ✅ Fixed | ❌ Usage-based | ❌ Usage-based | ❌ Usage-based |
| Per-minute fees | $0 | $3.99–$8.99/1k min | $4.00/1k min | $0.59–$0.99/1k min |
| Setup complexity | Medium | Low | Low | Low |
| Works in China (requires relay) | ✅ TURN relay | ✅ Built-in | ⚡ Limited | ✅ Built-in |
| Custom UI/UX freedom | ✅ Complete | ⚡ SDK-limited | ⚡ SDK-limited | ⚡ SDK-limited |
When to Use Each Platform — The Decision Framework
Choose Self-Hosted PeerJS WebRTC When:
- Your app will have 50+ daily active users making video calls — the fixed server cost becomes cheaper than per-minute APIs from this point
- Your application handles sensitive data — healthcare (HIPAA), finance, enterprise (GDPR), or any regulated industry where routing calls through third-party servers creates compliance risk
- You are building for Indonesia, India, or any region with data residency laws — PDSK, DPDP, and similar regulations are easier to comply with when data stays on your servers
- You want zero vendor lock-in — if Agora doubles their prices (they have done this before), you have no leverage. With self-hosted WebRTC, you own the infrastructure
- You need full UI/UX control — third-party SDKs impose UI patterns; WebRTC gives you complete freedom over the interface design li>You are building a long-term product — the infrastructure investment pays back within the first 3–6 months of real usage
Choose Agora / Twilio / Zegocloud When:
- You are building a prototype or MVP with fewer than 20 daily users — the managed service requires zero infrastructure setup
- You need a working demo in 48 hours for a pitch or investor presentation
- Your team has no backend or DevOps experience — running a TURN server requires server administration knowledge
- Your app serves users in China — Agora and Zegocloud have strong built-in China infrastructure; WebRTC through a TURN server in Hong Kong can work but requires more configuration
- The video calling feature is a minor add-on with very low usage — for truly minimal usage, a managed service can be cheaper than your minimum server costs
PeerJS WebRTC — Getting Started Code
Here is the minimum viable implementation of a 1:1 video call using PeerJS — the same foundation we use in production chat applications like Corex Messenger and Vemenne, built with our Node.js backend.
Step 1 — Install PeerJS
# For Node.js server (PeerJS signalling server)
npm install peer
# For your web client
npm install peerjs
# Or include via CDN
<script src="https://unpkg.com/peerjs@1.5.4/dist/peerjs.min.js"></script>
Step 2 — PeerJS Signalling Server (Node.js)
const { PeerServer } = require('peer');
const express = require('express');
const app = express();
// Mount PeerJS signalling server
const peerServer = PeerServer({
port: 9000,
path: '/peerjs',
// Add your own TURN server config for production
config: {
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' }, // Free STUN
{
urls: 'turn:your-turn-server.com:3478', // Your TURN
username: 'your_username',
credential: 'your_password'
}
]
}
});
peerServer.on('connection', (client) => {
console.log(`Peer connected: ${client.getId()}`);
});
app.listen(3000);
Step 3 — Client-Side Call Initiation
import Peer from 'peerjs';
// Connect to your own PeerJS signalling server
const peer = new Peer('my-unique-peer-id', {
host: 'your-server.com',
port: 9000,
path: '/peerjs',
secure: true
});
// Get user camera + microphone
const localStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: true
});
// Initiate call to another peer
const call = peer.call('remote-peer-id', localStream);
// When remote stream arrives - display it
call.on('stream', (remoteStream) => {
remoteVideoElement.srcObject = remoteStream;
});
// Handle incoming calls
peer.on('call', (incomingCall) => {
incomingCall.answer(localStream); // Answer with local stream
incomingCall.on('stream', (remoteStream) => {
remoteVideoElement.srcObject = remoteStream;
});
});
That is genuinely the core of a 1:1 video call. Three files, ~60 lines of code. The rest of your implementation effort goes into UI design, call state management (ringing, connected, ended), and TURN server configuration for production reliability — not the call technology itself.
Scaling Beyond 1:1 — Group Calls with SFU Architecture
Standard PeerJS uses a mesh network architecture where each participant connects directly to every other participant. This works well for 2–4 users in a call, but becomes bandwidth-intensive beyond that. For a call with 6 participants in a mesh, each person is sending 5 streams simultaneously — which can overwhelm mobile connections.
The SFU Solution
For group calls with 5+ participants, Primocys implements a Selective Forwarding Unit (SFU) — a WebRTC media server where each participant sends one stream to the SFU, and the SFU forwards the appropriate streams to each participant. This dramatically reduces per-user bandwidth requirements.
📐 Mesh Architecture (PeerJS, 4 users) vs SFU Architecture (MediaSoup, 6+ users)
MESH NETWORK (2-4 users)
Each user sends to every other user directly
✅ Works great — PeerJS default
SFU ARCHITECTURE (5+ users)
Each user sends 1 stream to SFU — receives selected streams back
✅ MediaSoup or Janus — open source, self-hosted
The open-source SFU options Primocys uses — MediaSoup and Janus — are the same category of technology Agora uses internally. The difference: Agora hosts it and charges per-minute; you host it on your own server and pay only for compute.
What We Actually Use in Production at Primocys
This is not a theoretical comparison. Here is exactly what we implemented in two live applications:
Corex Messenger — Enterprise B2B Chat
Built for Orbis Elite, Inc
- 1:1 calls: PeerJS WebRTC with direct P2P connections for ~83% of calls
- NAT fallback: Coturn TURN server deployed on AWS EC2 — handles the remaining ~17% of calls blocked by corporate firewalls
- Signalling: Custom Node.js signalling server integrated with the main chat WebSocket infrastructure
- Data: All call metadata and media stay on the client's own server — no third-party access
- Cost vs Agora: With ~50 enterprise users making calls regularly, we estimate saving $3,500–$4,200/year vs Agora HD pricing
Vemenne — Student Community App
Student & University Messenger
- 1:1 calls: PeerJS WebRTC — same P2P architecture
- Group study calls: MediaSoup SFU for calls with 3–8 participants — deployed on the same server cluster as the application
- Regional performance: TURN server deployed in Singapore region — lowest latency for Indonesian users across Telkomsel, Indosat, and XL mobile networks
- Mobile SDK: Flutter with native WebRTC bindings via flutter_webrtc package
Our standard architecture for all Primocys video calling projects: PeerJS + Coturn TURN server (for 1:1 and small groups) + MediaSoup SFU (for groups of 5+). This stack scales from 10 users to 100,000+ users with only infrastructure scaling — no change to the calling architecture, no change to per-minute pricing, and no change to data ownership.
What's Your Approximate Budget for This Project?
Every Instagram clone is unique — the investment depends on your feature set, platform choices, AI requirements, and target scale. Tell us about your project and we'll send a precise, no-obligation estimate within 24 hours.
Want to See a Live WebRTC Demo?
We don't just write about building chat apps — we've shipped them. Here are two live messaging platforms built and delivered by the Primocys team:
Mobile App WebRTC Demo
See self-hosted 1:1 video calling and group calls running in a Flutter app on real iOS and Android devices — no Agora SDK, no per-minute charges.
- Flutter + flutter_webrtc integration
- 1:1 calls + group SFU calls
- Same server powers iOS & Android
- Push notifications for incoming calls
Web App WebRTC Demo
See self-hosted WebRTC running in a React / Next.js web application — browser-native 1:1 video, group calls, and screen sharing with full data ownership.
- React / Next.js integration
- Screen sharing + file transfer
- Works across all major browsers
- Live demo on whoxachat.com
Conclusion
Choosing the right real-time video platform in 2026 comes down to one question: do you want convenience or control? Agora, Twilio, and Zegocloud deliver fast setup and managed infrastructure — but you pay per minute, per user, forever. Costs scale brutally as your app grows. A peerjs video call implementation or a fully self-hosted WebRTC solution gives you complete data ownership, zero per-minute fees, and full architectural control — exactly what we build at Primocys for production apps like Corex Messenger and Vemenne.
Our honest verdict:
- PeerJS / Self-Hosted WebRTC — Best for scale, cost & privacy
- Agora — Best for fastest MVP launch
- Zegocloud — Best for budget managed API
- Twilio — Most expensive at scale
If you are building a Flutter, React Native, React, or Next.js app and want real-time video without the recurring API bill — Primocys can build it for you.
