PeerJS
Backend / API library · Free
A wrapper for WebRTC data and media connections: it helps connect browser clients for peer-to-peer application features.
Also known as: peers/peerjs; peerjs

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Connect browser clients through WebRTC
- Create a peer connection and test transmission between two test clients
Example workflow
A possible workflow; this is not a report of hands-on testing.
Connect browser clients through WebRTC.
Before you start
- A data contract or HTTP workflow.
- A project with a supported runtime.
Steps
- Define data or media exchange between application participants.
- Create a peer connection and test transmission between two test clients.
- Add error handling and an integration check of the result.
Check your result
- Invalid and missing data are handled predictably.
- Types and the actual response agree; errors are not hidden.
Choosing PeerJS
Connect browser clients through WebRTC
Choose this when
- Connect browser clients through WebRTC
- Create a peer connection and test transmission between two test clients
Requirements
- The video call example requires a MediaStream from navigator.mediaDevices.getUserMedia and another peer's ID.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- The README lists testing in Firefox, Chrome, Edge, and Safari; other browsers may work but have no declared official support.
Frequently asked questions
What can you use for free in PeerJS?
Code and local use under MIT.
What additional costs might arise with PeerJS?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for PeerJS?
MIT for the code; dependencies have separate licenses.
How do you get started with PeerJS?
Define data or media exchange between application participants. Create a peer connection and test transmission between two test clients. Add error handling and an integration check of the result.
How does PeerJS transmit data and video streams?
For data, the example creates a connection through peer.connect(id), waits for open, and calls send; the receiving side handles connection and data. For calls, getUserMedia obtains a stream, peer.call sends it, and the recipient answers with call.answer.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- PeerJS
- API
- Development