Skip to content

@moq/publish

npmTypeScript

Publish media to MoQ broadcasts. Provides both a JavaScript API and a <hang-publish> Web Component, plus an optional <hang-publish-ui> SolidJS overlay.

Installation

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

Web Component

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

<hang-publish
    url="https://relay.example.com/anon"
    path="room/alice"
    audio video controls>
    <video muted autoplay></video>
</hang-publish>

Attributes:

  • url (required) — Relay server URL
  • path (required) — Broadcast path/name
  • device — "camera" or "screen" (default: "camera")
  • audio — Enable audio capture (boolean)
  • video — Enable video capture (boolean)
  • controls — Show publishing controls (boolean)

UI Overlay

Import @moq/publish/ui for a SolidJS-powered overlay with device selection and publishing controls:

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

<hang-publish-ui>
    <hang-publish
        url="https://relay.example.com/anon"
        path="room/alice"
        audio video>
        <video muted autoplay></video>
    </hang-publish>
</hang-publish-ui>

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

JavaScript API

typescript
import * as Publish from "@moq/publish";

const broadcast = new Publish.Broadcast(connection, {
    enabled: true,
    name: "alice",
    video: { enabled: true, device: "camera" },
    audio: { enabled: true },
});

// Reactive controls
broadcast.video.device.set("screen");
broadcast.name.set("bob");

Licensed under MIT or Apache-2.0