kasunk99-livestream-core
v0.3.40
Published
Reusable livestream viewer/host module for React Native (Expo) — mediasoup + Socket.IO
Readme
@livestream/core
Reusable livestream viewer (and later host) module for React Native / Expo. Talks to a mediasoup + Socket.IO livestream server.
Peer dependencies
Install in the host app:
react,react-nativereact-native-webrtc(required for video; use a dev build, not Expo Go)mediasoup-clientsocket.io-client
Setup
- Configure before using any component or hook:
import { setLivestreamConfig } from '@livestream/core';
setLivestreamConfig({
serverHttpUrl: 'http://localhost:3000', // or your server URL
getDisplayName: () => 'Viewer', // optional, for chat/room display
});- Use the feed or hooks:
import { LiveStreamFeed } from '@livestream/core';
<LiveStreamFeed />Or use useLiveStreams() and useViewerSocket(roomId) for custom UIs.
Exports
- Config:
setLivestreamConfig,getBaseUrl,getSignalingWsUrl,getDisplayName - Services:
fetchActiveStreams,ensureMediasoupGlobals - Hooks:
useViewerSocket,useLiveStreams - Components:
LiveStreamFeed,LiveStreamViewerItem - Types:
LiveStreamInfo,ProducerInfo,JoinRoomResult,RoomState
Server contract
- HTTP:
GET {serverHttpUrl}/api/live-streams→{ streams: { roomId, viewerCount, producerCount }[] } - WebSocket: Socket.IO at same origin (ws/https). Events:
join-room,create-webrtc-transport,connect-transport,produce,consume,get-producers,new-producer,room-updated, etc.
