# @moq/net

> The networking layer for Media over QUIC: real-time pub/sub with built-in caching, fan-out, and prioritization.

Latest version **0.4.4** (published 2026-10-17) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install @moq/net
pnpm add @moq/net
yarn add @moq/net
bun add @moq/net
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.4 |
| Published | 2026-10-17 |
| First published | 2026-05-18 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 5 |
| Unpacked size | 2.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1554 |
| Maintainers | kixelated |

## Links

- npm: https://www.npmjs.com/package/@moq/net
- Repository: https://github.com/moq-dev/moq
- Homepage: https://github.com/moq-dev/moq#readme
- Issues: https://github.com/moq-dev/moq/issues
- npm.io page: https://npm.io/package/@moq/net

## Dependencies (5)

- [bowser](https://npm.io/package/bowser.md) ^2.14.1
- [@moq/qmux](https://npm.io/package/@moq/qmux.md) ^0.3.3
- [async-mutex](https://npm.io/package/async-mutex.md) ^0.5.0
- [@moq/pattern](https://npm.io/package/@moq/pattern.md) ^0.2.1
- [@moq/signals](https://npm.io/package/@moq/signals.md) ^0.2.6

## Recent versions

- 0.4.4 (latest) — 2026-10-17
- 0.4.3 — 2026-10-11
- 0.4.2 — 2026-10-04
- 0.4.1 — 2026-09-26
- 0.4.0 — 2026-09-23
- 0.3.5 — 2026-09-09
- 0.3.4 — 2026-09-04
- 0.3.3 — 2026-08-25
- 0.3.2 — 2026-08-20
- 0.3.1 — 2026-08-16
- 0.3.0 — 2026-08-14
- 0.2.8 — 2026-08-13
- 0.2.7 — 2026-08-11
- 0.2.6 — 2026-08-10
- 0.2.5 — 2026-08-07
- … 15 more at https://npm.io/package/@moq/net/versions

## README

<p align="center">
	<img height="128px" src="https://github.com/moq-dev/moq/blob/main/.github/logo.svg" alt="Media over QUIC">
</p>

# @moq/net

[![npm version](https://img.shields.io/npm/v/@moq/net)](https://www.npmjs.com/package/@moq/net)
[![TypeScript](https://img.shields.io/badge/TypeScript-ready-blue.svg)](https://www.typescriptlang.org/)

A TypeScript [Media over QUIC](https://moq.dev/) (MoQ) client for both browsers and server JS/TS environments.
`@moq/net` is the **networking layer**: real-time pub/sub with built-in caching, fan-out, and prioritization, on top of QUIC. At session setup it negotiates one of two wire protocols, either the simplified [moq-lite](https://doc.moq.dev/concept/moq-lite) protocol or the full IETF [moq-transport](https://datatracker.ietf.org/doc/draft-ietf-moq-transport/) draft.

Check out [hang](../hang) for a higher-level media library that uses this package.

> **Note:** moq-lite is a subset of moq-transport and is forwards compatible with it, so this client works with any moq-transport CDN (ex. [Cloudflare](https://moq.dev/blog/first-cdn/)). See the [compatibility docs](https://doc.moq.dev/concept/moq-lite#compatibility) for details.

## Quick Start

```bash
npm add @moq/net
# or
pnpm add @moq/net
bun add @moq/net
yarn add @moq/net
# etc
```

## Server-side usage

`@moq/net` works on both browsers and servers, however in JS/TS server environments (Node, Bun) WebTransport is not yet available, so `@moq/net` will default to WebSockets communication with the relay.

Bun and Node v21+ have `WebSockets` built in, but older versions of Node do not, so for older versions of Node you will need the WebSockets polyfill to use `@moq/net`

```javascript
import WebSocket from 'ws';
import * as Moq from '@moq/net';
// Polyfill WebSocket for MoQ
globalThis.WebSocket = WebSocket;
```

You can optionally enable `WebTransport` and full HTTP3/Quic on server environments with the following (experimental) [polyfill](https://github.com/fails-components/webtransport)

```bash
npm install @fails-components/webtransport
npm install @fails-components/webtransport-transport-http3-quiche
```

Which you would load as follows

```javascript
import { WebTransport, quicheLoaded } from '@fails-components/webtransport';
global.WebTransport = WebTransport;
import * as Moq from '@moq/net'
await quicheLoaded; //This is a promise, connect after it resolves
```

## Examples

- **[Connection](examples/connection.ts)** - Connect to a MoQ relay server
- **[Publishing](examples/publish.ts)** - Publish data to a broadcast
- **[Subscribing](examples/subscribe.ts)** - Subscribe to and receive broadcast data
- **[Discovery](examples/discovery.ts)** - Discover broadcasts announced by the server
- **[Waiting](examples/wait.ts)** - Wait for one known broadcast to come online, and follow it
- **[Server side usage](https://github.com/sb2702/webcodecs-examples/tree/main/src/moq-server)** - Publish from browser to a server

## License

Licensed under either:

- Apache License, Version 2.0 ([LICENSE-APACHE](../../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](../../LICENSE-MIT) or http://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/@moq/net · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
