Skip to content

@moq/watch

npmTypeScript

Subscribe to and render MoQ broadcasts. Provides both a JavaScript API and a <moq-watch> Web Component, plus an optional <moq-watch-ui> SolidJS overlay.

Installation

bash
bun add @moq/watch
# or
npm add @moq/watch

Web Component

html
<script type="module">
    import "@moq/watch/element";
</script>

<moq-watch
    url="https://relay.example.com/anon"
    name="room/alice"
    controls>
    <canvas></canvas>
</moq-watch>

Attributes:

  • url (required) — Relay server URL
  • name (required) — Broadcast name
  • controls — Show playback controls (boolean)
  • paused — Pause playback (boolean)
  • muted — Mute audio (boolean)
  • volume — Audio volume (0–1, default: 1)

UI Overlay

Import @moq/watch/ui for a SolidJS-powered overlay with buffering indicator, stats panel, and playback controls:

html
<script type="module">
    import "@moq/watch/element";
    import "@moq/watch/ui";
</script>

<moq-watch-ui>
    <moq-watch
        url="https://relay.example.com/anon"
        name="room/alice">
        <canvas></canvas>
    </moq-watch>
</moq-watch-ui>

The <moq-watch-ui> element automatically discovers the nested <moq-watch> and wires up reactive controls.

JavaScript API

typescript
import * as Watch from "@moq/watch";

const broadcast = new Watch.Broadcast({
    connection,
    enabled: true,
    name: "alice",
    reload: true,
});

Licensed under MIT or Apache-2.0