Bitfocus Companion module to control Streamlabs Desktop (formerly Streamlabs OBS) through its local remote control API (JSON-RPC 2.0 over SockJS, port 59650).
See HELP.md for user documentation (how to get the API token, actions, feedbacks, variables, presets) and LICENSE.
- Connection to a local Streamlabs Desktop instance with token auth, automatic reconnection with backoff, full state resync after reconnect, Companion status reporting
- Scenes: set active scene (dropdown or by name with variable support and optional case-insensitive matching),
scene_activefeedback,current_scenevariables, real-time updates on manual scene switches - Scene collections: switch action,
collection_activefeedback,current_collectionvariable, automatic resync on collection changes - Source visibility: show / hide / toggle any scene item,
item_visiblefeedback, real-time tracking, dual output aware (horizontal, vertical or both displays) - Streaming / recording: toggle, start and stop actions (status-checked), feedbacks, raw status variables and
stream_duration/recording_durationlive timers - Replay buffer: toggle / start / stop / save actions, feedback and status variables
- Studio mode: toggle / enable / disable / execute transition (refused by Streamlabs while dual output is enabled)
- Audio: mute / unmute / toggle per source,
audio_mutedfeedback, onemute_<source>variable per source, real-timesourceUpdatedtracking, configurable scope (all sources or current scene) - Performance stats: CPU, FPS and dropped frames variables (2 s polling, optional) plus a dropped-frames threshold feedback
- Safety lock config option that disables the streaming actions (rehearsals, shared setups)
- Auto-generated presets: one per scene, STREAM / REC toggles with timers, replay buffer, one mute toggle per audio source, studio mode
- Transitions selection (the API exposes studio mode; picking transition types is not exposed)
- Notifications service
- Dual output per-context statuses (
status.horizontal/status.vertical)
Requirements: Node.js 22+, Yarn 4 (via corepack).
yarninstalls dependenciesyarn buildbuilds once intodist/, enough for the module to be loadable by Companionyarn devruns the compiler in watch mode (Companion hot-reloads dev modules on rebuild)yarn testruns the unit tests (JSON-RPC layer, reconnection state machine, state helpers)yarn lintlints the sourcesyarn packagebuilds and packages the module (companion-module-build)
To sideload the module during development, enable developer mode in Companion and point the "Developer modules path" to the parent folder of this repository.
Releases are automated by .github/workflows/release.yaml. To cut a release:
- Bump
versioninpackage.jsonand add aCHANGELOG.mdentry. - Commit on
main. - Tag the commit and push the tag:
git tag -a v1.0.0 -m "v1.0.0" git push origin v1.0.0
Pushing a v* tag runs lint/build/test, packages the module with companion-module-build, and publishes a GitHub Release with the .tgz attached (which can be imported into Companion via "Import offline module").
src/main.ts module instance: lifecycle, state sync, event wiring
src/config.ts config fields (host, port, secret token)
src/state.ts in-memory mirror of the Streamlabs state
src/slobs/connection.ts transport: SockJS + JSON-RPC 2.0 + auth + subscriptions + reconnect
src/slobs/types.ts protocol types
src/actions.ts action definitions
src/feedbacks.ts feedback definitions
src/variables.ts variable definitions
src/presets.ts auto-generated presets
The transport layer (SlobsConnection) is framework-independent and unit-tested with an injectable socket factory. The API token is never written to any log.
With Streamlabs Desktop running and Remote Control enabled (Settings > Remote Control):
yarn build
SLOBS_TOKEN=<your token> node scripts/smoke-test.js
The script connects, authenticates, lists scenes, then listens for sceneSwitched events for a few seconds. The token is read from the environment and never printed.
- Without a token: the connection shows
Bad configuration. - With a valid token and Streamlabs Desktop running: status
OK, variables populated. - Press a scene preset button: the scene switches in Streamlabs and the button turns red.
- Switch scenes manually in Streamlabs:
current_sceneand the feedbacks follow. - Start / stop the stream and the recording from Streamlabs or from Companion: feedbacks, variables and duration timers follow (
recording_statusalso passes throughwritingwhile the file is finalized). - Mute / unmute an audio source on both sides: feedback and
mute_<source>variable follow. - Show / hide a source on both sides: the
item_visiblefeedback follows. - Start / stop the replay buffer, save a replay while it runs.
- Quit and relaunch Streamlabs Desktop: the module reconnects and resynchronizes by itself.
- Auth is required even from localhost (
authonTcpServerService, first message). - Subscriptions are made by calling the event channel name on its service; events arrive as
{_type: 'EVENT', emitter: 'STREAM', resourceId, data}. - Async API methods reply with
{_type: 'SUBSCRIPTION', emitter: 'PROMISE'}and resolve through a laterEVENT; the transport layer handles this transparently. - The API only exposes
toggleStreaming/toggleRecording; explicit start / stop refetchgetModelfirst so a stale state can never invert the intent. - Mute uses the documented
AudioSource["<id>"].setMuted, withSourcesService.setMutedkept as a fallback (both verified live). - Scene item visibility uses
SceneItem["<sceneId>","<sceneItemId>","<sourceId>"].setVisibility(verified live, withitemUpdatedevents). - A collection that has ever been in dual output mode holds two copies of every scene item (
display: horizontal/vertical, same source and name), even once dual output is turned off.DualOutputService.sceneNodeMapspairs them (per scene, horizontal node id -> vertical node id).setVisibilityonly updates the copy it is called on, whereas the Streamlabs source list and hotkeys can update both. StreamingService.getModelalso carriesreplayBufferStatus, the*StatusTimetimestamps used by the duration timers, and per-context statuses when dual output is enabled.- Streamlabs silently refuses
enableStudioModewhile dual output is enabled; the module refetches the state after the call and warns instead of trusting the event.