Project structure
Setup and running
1
Clone the repository
2
Install dependencies
3
Start the dev server
http://localhost:3000/YOUR_PROJECT_ID in your browser.URL parameters
The example reads configuration from the URL:
Example URL:
http://localhost:3000/abc123?sfuPlayer=true&streamerId=host1
Feature toggles
At the top ofApp.js:
Set
SHOW_DEV_TOOLS to false before deploying to production. The Developer Tools panel exposes console commands, JSON messaging, and mic/camera controls that are intended for development only.LOADING_CONFIG
The example centralizes all loading screen text and colors in a single configuration object:How the example wires SDK events
SDK initialization
The app initializes inside auseEffect hook that runs when projectId is available:
Lifecycle events to loading progress
Each WebRTC event updates React state for the loading screen:Reconnection to loading screen
The reconnection state drives the loading screen back into view:AFK warning to custom overlay
The example replaces the default AFK overlay with a styled card:dismissAfkRef.current().
Developer Tools panel
WhenSHOW_DEV_TOOLS is true, the example shows a panel with these sections:
Stream controls toolbar
The bottom-right toolbar shows after loading completes:- Mute/Unmute — Toggles both video and audio elements
- Fullscreen — Toggles browser fullscreen mode
- Stream Info — Shows stats from
UIControl.getStreamStats() - Settings (if resolution enabled) — Resolution selection dropdown
- Dev Tools (if enabled) — Opens the Developer Tools panel
Key React patterns used
useReffor SDK instances (pixelStreamingRef,appStreamRef,uiControlRef) — avoids re-rendersuseStatefor UI state (loading, controls, AFK, stats)useCallbackfor event handlers (mute, fullscreen, dev tools actions)mountedflag in useEffect to prevent state updates after unmount- Event handler
stopPropagationon dev tools inputs to prevent keyboard events from reaching the stream
Next steps
Custom loading screen
Build a loading screen driven by SDK lifecycle events.
Troubleshooting
Resolve common SDK integration issues.