Check out example codes for "peerjs". It will help you in understanding the concepts better.

Code Example 1

<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>

Code Example 2

var peer = new Peer();

Learn ReactJs, React Native from akashmittal.com