MoQ is the most-talked-about new low-latency live-streaming protocol right now. It promises sub-second latency with the caching and fan-out economics of a content delivery network (CDN), aiming to combine WebRTC‘s real-time speed with the broadcast scale that HLS (HTTP Live Streaming) and DASH (Dynamic Adaptive Streaming over HTTP) are known for. Media over QUIC Transport is also a moving IETF draft, which raises the question any team considering it has to answer: can you build a working application on MoQ today. Or is MoQ still a lab experiment you shouldn’t bet a sprint on?
We answered it the only way that counts: by building one. This post walks through a working one-to-many live broadcast, built in two halves (a publisher and a viewer), and covers each protocol-level choice at the step where it affects the build.
The demo is open source and available on the WebRTC.ventures GitHub. It is a browser broadcaster and viewer built on MOQtail, a MoQ toolkit with its own relay, pinned to draft-16. Later drafts are covered below.
MoQ vs. WebRTC was explored in depth on WebRTC Live Episode 119: WebRTC, MoQ, or Both? A QUIC Study.
How MoQ Works: Tracks, Groups, and Objects
MoQ Transport (MOQT) is a publish/subscribe protocol that runs over QUIC (the same transport underneath HTTP/3) reaching the browser through the WebTransport API. Instead of a publisher pushing a connection-oriented stream to a server, publishers announce content and subscribers pull what they want. Relays sitting between them fan a single publisher out to many subscribers. That pull-based, relay-friendly shape is why MoQ caches and scales like a CDN while staying real-time.
The data you publish is organized as a hierarchy, and you design against every level of it:
- Namespace / track. A track is one continuous media stream (for us, one quality level). The namespace groups a broadcast’s tracks together.
- Group. An independently decodable span of a track. For video, one group per group-of-pictures (GOP), starting at a keyframe.
- Object. The smallest unit, carrying one media payload (for us, one encoded frame) plus priority and an end-of-group marker.

The reason this hierarchy exists, and the reason MoQ chose QUIC, is that QUIC carries many independent streams on one connection, so a lost packet stalls only its own stream. HLS and DASH are traditionally delivered over Transmission Control Protocol (TCP), whose single reliable, in-order stream is exactly what makes them robust and cache-friendly for on-demand and buffered playback, but it also means one lost packet holds up everything queued behind it (head-of-line blocking).
For live media that is willing to skip stale data, MoQ takes the other side of that tradeoff: it can drop an old group and keep the newest media flowing.
One consequence that surfaces immediately in development is that, since WebTransport rides QUIC, every MoQ connection uses TLS. This means even local development needs a trusted or pinned certificate. Our demo uses mkcert to install a locally-trusted CA.
With the model in hand, building a MoQ app is two halves: a publisher that puts media on the relay, and a viewer that pulls it off. Here is each.
Publishing to a MoQ Relay
The publisher’s job is to connect to the relay, announce a namespace, publish a track, and then feed encoded frames into it as MoQ objects. A track is a live stream of objects, so you publish the empty track first and only start feeding encoded frames once it is live. In code, the spine is:
// Publisher: camera → encoder → MoQ objects → relay
const client = await MOQtailClient.new({ url: relayUrl })
await client.publishNamespace(Tuple.fromUtf8Path(namespace))
// A track is a live stream of objects. Create it (capturing its controller),
// register it, and publish it, before any media flows into it.
let controller: ReadableStreamDefaultController<MoqtObject>
const objects = new ReadableStream<MoqtObject>({ start: (c) => (controller = c) })
const track = client.addOrUpdateTrack({ fullTrackName, trackSource: { live: objects } })
await client.publish(fullTrackName, /* forward */ true, track.trackAlias)
// The encoder feeds that already-published stream: each encoded frame is mapped
// into the hierarchy and enqueued as one object.
const encoder = new VideoEncoder({
output: (chunk) => {
const where = assignFrame(counter, chunk.type === 'key') // map the frame into the hierarchy
controller.enqueue(toMoqtObject(where, chunk)) // one object per frame
},
error: (e) => report(e),
})
encoder.configure({ codec: 'avc1.640028', width, height, bitrate })
// Finally, capture the camera and push its frames through the encoder.
const media = await navigator.mediaDevices.getUserMedia({ video: true })
// ...read frames from `media` and call encoder.encode(frame)
publishNamespace advertises the broadcast, addOrUpdateTrack with a live source puts the track on the SUBSCRIBE (live) path, and publish makes it available through the relay. In our example, the broadcast carries three tracks this way (720p, 480p, and 360p) so a viewer can pick a quality.
Capture and encoding are not MoQ’s concern. getUserMedia (the browser’s Media Capture API, the same one WebRTC uses) grabs camera frames, and WebCodecs’ VideoEncoder compresses them. MoQ begins only once you have encoded frames to carry: it is a transport, so it slots in behind whatever produces your media.
The one part the protocol leaves entirely to you is how a frame becomes an object. MoQ gives you the hierarchy of tracks, groups and objects, but says nothing about how your media maps onto it, because it is deliberately media-agnostic.
That mapping is where the quality of a live broadcast is won or lost. We use Subgroup forwarding (an ordered QUIC stream per group, right for video that must decode in order), one group per group-of-pictures aligned to a keyframe, one object per frame, and mark keyframes higher priority than delta frames. The grouping itself is a small pure function, which keeps it testable:
// A keyframe opens a new group (new GOP); a delta frame extends the current one.
// Grouping follows the emitted chunk type (isKey), never the requested cadence,
// so a keyframe emitted early still correctly starts a new group.
export function assignFrame(counter: GroupCounter, isKey: boolean): FrameAssignment {
if (isKey) {
counter.groupId += 1n // new group == new GOP, starts at a keyframe
counter.objectId = 0n
return { groupId: counter.groupId, objectId: 0n,
priority: KEYFRAME_PRIORITY, // keyframes beat delta frames
forwardingPreference: ObjectForwardingPreference.Subgroup }
}
const objectId = counter.objectId
counter.objectId += 1n // delta frame extends the current group
return { groupId: counter.groupId, objectId,
priority: DELTA_PRIORITY,
forwardingPreference: ObjectForwardingPreference.Subgroup }
}
Each of those choices has a wrong answer, and each wrong answer breaks something specific:
- Wrong forwarding preference. Send ordered video over
Datagram(unreliable, unordered) and lost frames show up as visible artifacts, because the decoder never gets the frames it depends on. - Groups not aligned to keyframes. If a group starts mid-GOP, a viewer joining there has no keyframe to decode from and sees nothing until the next one arrives.
- Objects too coarse. Pack a whole group into one giant object and the relay can no longer deliver it partially or prioritize the keyframe inside it, so the drop-and-prioritize machinery has nothing to work with.
Subscribing: From the Relay to the Screen
The viewer connects to the same relay, subscribes to one track at the live edge, and feeds each delivered object into a Media Source Extensions (MSE) buffer that drives a <video> element. The filterType parameter is what starts playback at the live edge rather than from the beginning, one of a few choices, (each a single call or parameter) that decide what the viewer experiences. Here is the call, with those choices explained below it:
// Viewer: relay → MoQ objects → MSE → <video>
const client = await MOQtailClient.new({ url: relayUrl })
const { stream } = await client.subscribe({
fullTrackName,
filterType: FilterType.NextGroupStart, // join at the live edge (see below)
groupOrder: GroupOrder.Original,
forward: true,
})
for await (const object of stream) { // ReadableStream<MoqtObject>
if (object.payload) sourceBuffer.appendBuffer(object.payload.buffer) // → <video>
}
Two of those choices are visible on screen the moment they are wrong.
- Where a late viewer starts. Someone joining mid-broadcast has to begin somewhere in the track. If they begin at the earliest group, they replay from the start; mid-group and/or before a keyframe, the decoder has nothing to decode. The
NextGroupStartfilter above begins at the top of the next group (a keyframe) so a late viewer sees live video within one group instead of a replay. That one enum value is the entire join-late behavior. - Switching quality without a glitch. Moving between the 720p, 480p, and 360p tracks is how a viewer adapts to changing bandwidth. If you switch mid-group, the new track’s frames arrive before their keyframe, so the picture stutters or goes black until the next one. Applying the switch at a group boundary, re-initializing the decoder when the new track’s first object (a keyframe) arrives, which keeps the timeline continuous. Group-boundary track switching is an active topic in the MoQ working group, so building it this way tracks where the protocol is heading.
The subscribe call above is the live way to request a track: it delivers new objects as they are produced. MoQ also offers a recorded way, FETCH, which retrieves already-published objects as one ordered stream, the right tool for an archived replay or VOD. (If you run the demo, the <video> scrubber will let you drag backward, but that is replaying the browser’s own buffer of what you have already watched, not a FETCH to the relay for frames from before you joined.)
With both halves built, the payoff is what happens when more than one viewer connects and when the network gets worse.
Watching It Fan Out and Stay Live
The clip above shows the relay doing fan-out: open a second viewer on the same namespace and two viewers play simultaneously from one publish path, with the relay duplicating delivery rather than the broadcaster re-encoding. One-to-many works exactly as the pull-based model promises, so adding viewers adds no work on the publisher.
One of MoQ’s headlines is that it stays live under congestion. This comes from two layers working together rather than from application code:
- The relay and QUIC prioritize newest media. Under bandwidth pressure, MoQ favors the newest groups and lets older group data drop rather than queueing it. The working-group guidance is explicit that prioritizing the newest groups is the right default for live video.
- The viewer tracks the live edge. When data falls behind, the player seeks to the newest buffered position instead of playing out a growing backlog.
Together these produce the behavior that defines low-latency live: when the network degrades, playback skips stale media and stays at the live edge. A buffered, TCP-based protocol like HLS or DASH makes the opposite choice by design, preserving every segment in order, which is ideal when completeness matters more than immediacy. For live, where being current wins, staying at the edge is where MoQ fits best.
That raises the natural next question: what does it take to move this off localhost?
Adopting MoQ for Real
The demo runs against a local relay, but the architecture is built for a CDN, and MoQ’s design makes that transition unusually clean. What takes care is matching a draft’s optional paths to what a given relay has implemented.
From a Local Relay to a MoQ CDN
A MoQ relay is deliberately a dumb pipe: it forwards objects and knows nothing about your codecs, tracks, or application logic. Everything above it (the publisher and viewer you just saw) is portable, and the client is relay-agnostic: point it at a different relay URL and it connects. The certificate wall even disappears, since a CDN presents a real publicly-trusted certificate and the local mkcert step is development-only. Cloudflare runs a MoQ relay network supporting MoQ Transport draft-14, draft-16, draft-18. Our demo pins draft-16.
But swapping the relay URL is the whole story for only one half of the app. The publisher also depends on which publishing path and auth scheme the relay supports.
Subscribing Travels; Publishing Takes Work
Pointing a subscriber at a CDN really is close to a URL change: a pure SUBSCRIBE client makes few demands on the relay beyond the subscribe path. Pointing a publisher at the same CDN takes a bit more, and a matching draft number alone won’t tell you how much.
Cloudflare publishes a per-draft feature matrix today. Other vendors are arriving, each its own matrix to check. As of writing this post, Cloudflare’s draft-16 relay does not expose FETCH, so the archived-replay path (the counterpart to the live SUBSCRIBE) isn’t a drop-in even against a major CDN.
A subscriber against a public demo stream is a quick first proof, and a publisher is a bounded next step: match your ingest path to what the relay implements, and wire up its auth. That is the real adoption work: choosing a library, draft, and relay that line up for publishing and keeping them aligned as the drafts advance. It is ordinary integration work, not a wall.
PUBLISH_NAMESPACE vs PUBLISH
There are two ways to publish, and relays may support one before the other. Draft-16 gives a publisher two complementary paths (spec §8.5): PUBLISH, which pushes a specific track to the relay, and PUBLISH_NAMESPACE, which advertises a namespace and lets the relay pull tracks on demand as subscribers ask for them.
They do different jobs (announce-and-pull versus push) and both are part of draft-16. Our broadcaster uses the PUBLISH_NAMESPACE announce model, which MOQtail implements. Cloudflare’s draft-16 relay implements the PUBLISH ingest path but not PUBLISH_NAMESPACE yet (it lists that message under its draft-14 and draft-18 support).
So porting our publisher to Cloudflare means switching to the PUBLISH ingest path the relay already speaks.
Authentication
Two different tokens, two different channels. First you authenticate to Cloudflare’s management API with an ordinary account API token (Authorization: Bearer …) to provision a relay; that call auto-issues two MoQ relay tokens, one that can publish and subscribe, one that can only subscribe.
Those relay tokens are the second channel: a publisher or subscriber presents one to the relay when it opens the MoQ connection (Cloudflare’s demo relays carry it in the connect URL as a JWT), not as an HTTP header the browser sets. So the client library has to know how to carry the relay token into the MoQ session.
From MoQ Demo to Production: What to Add
Four capabilities sit on top of the publisher and viewer, not in place of them:
- Adaptive bitrate. The broadcast switches quality on demand; production chooses automatically from measured bandwidth.
- Codec negotiation. The three tracks share one H.264 codec; production negotiates packaging and codecs per client.
- Clock-synced latency. The glass-to-glass latency readout assumes the broadcaster and viewer share a clock (same machine or NTP-synced hosts).
- Buffer management. The viewer keeps everything it has played, which is what lets you scrub back like a DVR, while production trims to a sliding window near the live edge to cap memory on long sessions.
You’re Not Early Alone
Betting on a draft sounds risky until you notice who is already in production on it. nanocosmos reports MoQ deployed at commercial scale with real viewer-traffic benchmarks, Vindral presented its MoQ work at RTC.ON 2026, eleven vendors interoperated at NAB Show 2026, and the ecosystem is consolidating through the OpenMOQ Consortium (Red5, Fishjam, Synamedia) rather than fragmenting the way early WebRTC did. Adopting MoQ now means pinning a draft and accepting that constraint, a known, navigable cost, not a gamble.
Start From the Working Demo
MoQ is buildable today. A real one-to-many broadcast with instant join-late, glitch-free quality switching and staying live under load, comes down to a publisher that maps media into tracks, groups, and objects, and a viewer that joins at the live edge and switches cleanly. Get those two halves right and the transport delivers the low-latency behavior that makes MoQ worth adopting.
Clone the demo at github.com/WebRTCventures/moq-broadcast-demo, run the relay, and open two viewers on one broadcast. Then change how it maps frames to groups, or where the viewer starts, and watch what breaks. That is the fastest way to see why each piece is built the way it is.
If you are weighing MoQ for a product and want help navigating the draft-and-lineage question or taking a broadcast to production scale, we build real-time media systems for a living.
Further Reading:
