New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-mse-player

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-mse-player

React component for streaming video using Media Source Extensions (MSE) - designed for go2rtc

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
13
-67.5%
Maintainers
1
Weekly downloads
 
Created
Source

React MSE Player

CI NPM Version NPM Downloads License

React components for low-latency video streaming via MSE and WebRTC. Designed for go2rtc.

Features

  • MSEVideoStream — low-latency streaming over WebSocket using Media Source Extensions.
  • WebRTCVideoStream — ultra-low-latency streaming via WebRTC with WebSocket signalling.
  • Automatic reconnection with stall detection and smart backoff.
  • Full TypeScript support with comprehensive type definitions.
  • Smart buffering — internal queue and automatic memory trimming to prevent quota errors (MSE).
  • Broad codec support — H.264, H.265 (HEVC), AAC, FLAC, Opus negotiated automatically.
  • ManagedMediaSource — iOS 17+ support (MSE).
  • TCP-only ICE — optional restriction for WebRTC in firewall-heavy environments.
  • Translatable UI — override all user-facing strings via the labels prop.

Installation

npm install react-mse-player
# or
yarn add react-mse-player

Usage

MSE

import { MSEVideoStream } from 'react-mse-player';

<MSEVideoStream src="ws://localhost:1984/api/ws?src=camera1" />

WebRTC

import { WebRTCVideoStream } from 'react-mse-player';

<WebRTCVideoStream src="ws://localhost:1984/api/ws?src=camera1" />

Both components accept a ws:// or wss:// URL. HTTP/HTTPS URLs are converted automatically. Relative paths (/api/ws?src=...) are also supported.

Choosing between MSE and WebRTC

MSEWebRTC
Latency~1–3 s< 500 ms
Safari iOS17+ only11+
Firewall-friendlyYes (WS)Needs STUN/TURN
Audio/Video syncGoodExcellent

Use WebRTC when latency matters most. Use MSE as a fallback for broader compatibility.

Advanced example

import { WebRTCVideoStream, MSEVideoStream } from 'react-mse-player';

// WebRTC with custom ICE servers and TCP-only mode
<WebRTCVideoStream
  src="ws://localhost:1984/api/ws?src=camera1"
  mode="webrtc/tcp"
  pcConfig={{
    iceServers: [{ urls: 'turn:my-turn-server.com', username: 'user', credential: 'pass' }],
  }}
  media="video,audio"
  onStatus={(s) => console.log(s)}
  onError={(e) => console.error(e)}
  debug
/>

// MSE with stall detection timeout
<MSEVideoStream
  src="ws://localhost:1984/api/ws?src=camera1"
  dataTimeout={5000}
  media="video,audio"
  onStatus={(s) => console.log(s)}
  onError={(e) => console.error(e)}
  debug
/>

Props

Shared props (both components)

PropTypeDefaultDescription
srcstringRequiredWebSocket URL (ws://, wss://, relative / path, or http(s):// auto-converted).
widthstring | number'100%'Container width.
heightstring | number'100%'Container height.
autoPlaybooleantrueStart playback automatically.
controlsbooleanfalseShow native video controls.
mediastring'video,audio'Requested tracks: 'video', 'audio', or 'video,audio'.
objectFitstring'contain'CSS object-fit for the video element.
onStatus(status: string) => voidStatus change callback.
onError(error: any) => voidError callback.
classNamestring''CSS class for the container.
styleCSSProperties{}Inline styles for the container.
labelsVideoLabelssee belowOverride user-facing strings (for translation).
debugbooleanfalseLog connection events to the console.

MSEVideoStream-only props

PropTypeDefaultDescription
dataTimeoutnumber10000Milliseconds without data before triggering a reconnect.

WebRTCVideoStream-only props

PropTypeDefaultDescription
mode'webrtc' | 'webrtc/tcp''webrtc'Use 'webrtc/tcp' to restrict ICE candidates to TCP only.
pcConfigRTCConfigurationCloudflare + Google STUNOverride ICE servers or bundle policy.

VideoLabels

All fields are optional — omit any key to keep the English default.

KeyDefault
streamNotFound"Stream not found"
connectionFailed"Connection failed"
reconnecting"Reconnecting..."
import type { VideoLabels } from 'react-mse-player';

const labels: VideoLabels = {
  streamNotFound: "Flux introuvable",
  connectionFailed: "Connexion échouée",
  reconnecting: "Reconnexion...",
};

<WebRTCVideoStream src={url} labels={labels} />

Status values

StatusDescription
connectingOpening the WebSocket connection.
openWebSocket connected, negotiating stream.
streaming(MSE) Data flowing, buffer active.
connected(WebRTC) Peer connection established.
reconnectingConnection lost, waiting to retry.
closedConnection closed.
errorUnrecoverable error.

Browser Support

BrowserMSEWebRTC
Chrome / Edge / Brave
Firefox
Safari 17+✅ (ManagedMediaSource)
Safari < 17✅ (11+)
Android (Chrome)
iOS Safari 17.1+
iOS Safari < 17

License

MIT

Keywords

react

FAQs

Package last updated on 02 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts