Docs

Send audio and video streams

Trystero wraps WebRTC media plumbing so you can attach camera, microphone, or screen-share streams to peers in a room.

Add a local stream

Add a media stream once for the current room, then add it for peers who join later.

const localStream = await navigator.mediaDevices.getUserMedia({
  audio: true,
  video: true
})

room.addStream(localStream)

room.onPeerJoin = peerId => {
  room.addStream(localStream, {target: peerId})
}

Receive peer streams

Set onPeerStream to attach incoming streams to video or audio elements.

room.onPeerStream = (stream, peerId, metadata) => {
  const video = getPeerVideo(peerId)
  video.srcObject = stream
  video.play()
}

Attach metadata

Metadata helps distinguish cameras, microphones, screen shares, and other stream types in your UI.

const screen = await navigator.mediaDevices.getDisplayMedia({
  video: true,
  audio: true
})

room.addStream(screen, {
  metadata: {kind: 'screen-share'}
})