Documentation Index
Fetch the complete documentation index at: https://mintlify.com/moq-dev/moq/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Moq provides libraries for both Rust and TypeScript/JavaScript, allowing you to build native applications or browser-based solutions.
Choose Your Language
Rust
TypeScript/JavaScript
Rust Installation
Moq provides several Rust crates for different use cases.Prerequisites
- Rust 1.70 or later
- Cargo (comes with Rust)
Core Libraries
[dependencies]
moq-lite = "0.15.0"
Available Crates
| Crate | Version | Description |
|---|
| moq-lite | 0.15.0 | Core pub/sub transport protocol with built-in concurrency and deduplication |
| hang | 0.15.1 | Media-specific encoding/streaming layered on top of moq-lite |
| moq-native | Latest | Opinionated helpers to configure a Quinn QUIC endpoint |
| moq-token | Latest | Authentication scheme with JWT token support |
| moq-mux | Latest | Media muxers and demuxers (fMP4/CMAF, HLS) |
| libmoq | Latest | C bindings for moq-lite |
Moq provides command-line tools for publishing and token generation:cargo install --git https://github.com/moq-dev/moq moq-cli
Optional Features
Some crates support optional features:[dependencies]
moq-lite = { version = "0.15.0", features = ["serde"] }
moq-native = { version = "0.5", features = ["iroh"] }
Available features:
serde - Enable serialization support
iroh - Enable P2P connections via iroh
quinn - Use Quinn as QUIC backend (default)
quiche - Use Quiche as QUIC backend
Documentation
View Rust documentation:Or visit docs.rs for online documentation:TypeScript/JavaScript Installation
Moq provides npm packages for browser-based applications.Prerequisites
- Node.js 18+ or Bun 1.0+
- A package manager: npm, pnpm, yarn, or bun
The Moq team uses Bun for development. While npm, pnpm, and yarn should work, Bun is recommended for the best experience.
Core Libraries
npm install @moq/lite
npm install @moq/hang
npm install @moq/watch
npm install @moq/publish
Available Packages
| Package | Version | Description |
|---|
| @moq/lite | 0.1.5 | Core pub/sub transport protocol for browsers |
| @moq/hang | 0.2.0 | Core media library: catalog, container, and support |
| @moq/watch | 0.2.2 | Subscribe to and render MoQ broadcasts (Web Component + JS API) |
| @moq/publish | Latest | Publish media to MoQ broadcasts (Web Component + JS API) |
| @moq/token | Latest | Authentication library & CLI for JS/TS environments |
| @moq/ui-core | Latest | Shared UI components for watch and publish |
Using Web Components
The easiest way to use Moq in the browser is with Web Components:<!DOCTYPE html>
<html>
<head>
<script type="module">
import '@moq/watch/ui'
</script>
</head>
<body>
<moq-watch
url="https://relay.moq.dev/demo"
name="bbb"
></moq-watch>
</body>
</html>
Using the JavaScript API
For more control, use the JavaScript API directly:import { Client } from '@moq/lite'
import { Broadcast } from '@moq/hang'
// Connect to relay
const client = await Client.connect('https://relay.moq.dev/demo')
// Subscribe to a broadcast
const broadcast = new Broadcast(client, 'bbb')
await broadcast.ready()
// Access tracks
const tracks = broadcast.tracks()
console.log('Available tracks:', tracks)
The token generation tool can be installed globally:npm install -g @moq/token
Then use it:TypeScript Configuration
For TypeScript projects, ensure your tsconfig.json includes:{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"types": ["@types/web"]
}
}
Verifying Installation
Create a simple test to verify your installation:use moq_lite::Origin;
fn main() {
let origin = Origin::new();
println!("Moq origin created successfully!");
}
Run it: Create a simple test to verify your installation:import { Client } from '@moq/lite'
console.log('Moq installed successfully!')
console.log('Client:', Client)
Run it:bun test.ts
# or
node test.ts
Development Setup
If you want to contribute to Moq or modify the source code:
Clone the repository
git clone https://github.com/moq-dev/moq.git
cd moq
Install development dependencies
On macOS, you may need to install additional dependencies:
On Linux, ensure you have development headers:Ubuntu/Debian:sudo apt-get install build-essential pkg-config libssl-dev ffmpeg
Fedora:sudo dnf install gcc pkg-config openssl-devel ffmpeg
Windows support is experimental. We recommend using WSL2 (Windows Subsystem for Linux) for the best experience:Then follow the Linux installation instructions inside WSL.
Next Steps
Quick Start
Run the demo application
Architecture
Understand Moq’s layered design
Publishing
Start publishing media streams
Watching
Subscribe to and watch streams