Index of every page on this site: llms.txt
All skills
Run it yourself

Browser-only React SDK for Fishjam — joining rooms, capturing camera/microphone/screen, displaying peers, and acting as a livestream streamer or viewer in a React web app. Use whenever the user is writing a React app in a browser that calls Fishjam APIs, sets up FishjamProvider, or uses any Fishjam React hook. Trigger on: '@fishjam-cloud/react-client', 'FishjamProvider', 'useConnection', 'useCamera', 'useMicrophone', 'useScreenShare', 'usePeers', 'useDataChannel', 'useVAD', 'useLivestreamStreamer', 'useLivestreamViewer', 'useCustomSource', 'useInitializeDevices', 'useUpdatePeerMetadata', 'useSandbox', 'PeerWithTracks', 'joinRoom', 'peerToken', 'fishjamId', 'fishjam react', '@fishjam-cloud/ts-client', 'FishjamClient ts-client'. Covers the provider, the full hook catalog, simulcast configuration, custom sources, data channels, VAD, livestream WHEP playback, device persistence, and reconnection. Briefly notes when to drop down to @fishjam-cloud/ts-client for non-React or worker contexts.

  • 10 files
  • 51.3 KB
  • MIT
  • Updated 6 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/react-client

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

ts-client-escape.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Dropping to @fishjam-cloud/ts-client

@fishjam-cloud/react-client is a thin React wrapper over @fishjam-cloud/ts-client. If you're not in React (Svelte, Vue, vanilla TS in a Vite app, a web worker, a Node-style headless harness), use ts-client directly.

Install

npm install @fishjam-cloud/ts-client

Construct a client

import { FishjamClient } from '@fishjam-cloud/ts-client';

const client = new FishjamClient({
  reconnect: true,    // or false / ReconnectConfig
  debug: false,
});

This is the same class that FishjamProvider constructs internally. Pass your own instance back into the provider via fishjamClient={...} if you also need it from React.

Connect

// Pass the host root only — FishjamClient.connect appends `/socket/peer/websocket` itself.
const fishjamUrl = `wss://fishjam.io/api/v1/connect/${FISHJAM_ID}`;
// (or build via the same `httpToWebsocketUrl(resolveFishjamUrl(fishjamId))` logic the React hook uses)

await client.connect({
  url: fishjamUrl,
  token: peerToken,
  peerMetadata: { name: 'alice' },
});

Status changes via events:

client.on('joined', () => console.log('connected'));
client.on('disconnected', () => console.log('disconnected'));
client.on('authError', (reason) => console.error('auth error', reason));

React-equivalent operations

React hook ts-client equivalent
useConnection().joinRoom client.connect({ url, token, peerMetadata })
useConnection().leaveRoom client.disconnect()
usePeers().remotePeers client.getRemotePeers() and 'trackReady' / 'trackRemoved' events
useCamera().cameraStream Construct your own MediaStream; publish via client.addTrack(track, metadata, simulcastConfig)
useScreenShare().startStreaming await navigator.mediaDevices.getDisplayMedia(...) then client.addTrack(...)
useDataChannel().publishData client.publishData(data, options) after client.createDataChannels()
useDataChannel().subscribeData client.subscribeData(callback, options)
useLivestreamStreamer().connect import { publishLivestream } from '@fishjam-cloud/ts-client'
useLivestreamViewer().connect import { receiveLivestream } from '@fishjam-cloud/ts-client'

The React hooks just translate these primitives into reactive state. The semantics are identical.

Minimal vanilla TS app

import { FishjamClient, publishLivestream, receiveLivestream } from '@fishjam-cloud/ts-client';

async function main() {
  const client = new FishjamClient({ reconnect: true });

  client.on('joined', () => console.log('joined'));
  client.on('trackReady', (trackContext) => {
    const video = document.createElement('video');
    video.srcObject = trackContext.stream;
    video.autoplay = true;
    document.body.appendChild(video);
  });

  await client.connect({
    url: `wss://fishjam.io/api/v1/connect/<FISHJAM_ID>`, // no trailing path — client appends /socket/peer/websocket
    token: peerToken,
    peerMetadata: {},
  });

  // Get media:
  const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
  for (const track of stream.getTracks()) {
    const type = track.kind === 'video' ? 'camera' : 'microphone';
    await client.addTrack(track, { type, paused: false });
  }
}

See examples/web-ts/minimal/ and simple-app/ in the SDK monorepo for full working examples.

When NOT to drop to ts-client

If your app is React, stay in React. The hooks save you from event-listener spaghetti, device persistence boilerplate, and reactivity glue. The "escape hatch" is for genuinely non-React code paths.

You can also do both — use the React hooks for UI and grab the client via fishjamClient prop on the provider for one specific advanced flow.

Sources

  • @fishjam-cloud/ts-client exports (re-exported types include AuthErrorReason, JoinErrorReason, Metadata, ReconnectConfig, ReconnectionStatus, SimulcastConfig, SimulcastBandwidthLimit, TrackBandwidthLimit, Variant)
  • examples/web-ts/minimal/src/main.ts in the SDK monorepo (canonical vanilla example)
  • examples/web-ts/simple-app/ in the SDK monorepo (multi-track example)
  • The React client source — every hook is a thin wrapper that calls ts-client methods

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 6 months ago

README badge

README badge for software-mansion-labs/skills/react-client