JSFiddle - React, Tailwind, and code Playground

JavaScript

const config = {
  iceServers: [
    { urls: 'stun:stun.l.google.com:19302' },
    { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }
  ]
}

const pc1 = new RTCPeerConnection(config) 

function waitForIce(conn, desc) {
  return new Promise(function (resolve) {
    conn.onicecandidate = event => {
      if (!event.candidate) {
        // We didn't find any more ice candidates
        resolve()
      }
    }
    conn.setLocalDescription(desc)
  })
}

const channel = pc1.createDataChannel('label')
channel.onopen = function() {
  channel.send('jsfiddle says hello')
}

async function start() {
  // Don't trickle (wait untill it don't find any more icecandidates)
  await waitForIce(pc1, await pc1.createOffer())
  prompt('this is my description, set other peers remote description to this', JSON.stringify(pc1.localDescription.toJSON()))
  await pc1.setRemoteDescription(JSON.parse(prompt('what is now his localDescription?')))
}

start().catch(console.log)