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.

connection.md

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

Connection & Sandbox

useConnection

The hook for joining/leaving rooms and reading status. Source: @fishjam-cloud/react-client → packages/react-client/src/hooks/useConnection.ts.

import { useConnection } from '@fishjam-cloud/react-client';

function Room() {
  const { joinRoom, leaveRoom, peerStatus, reconnectionStatus } = useConnection();
  // ...
}

joinRoom({ peerToken, peerMetadata? })

await joinRoom({ peerToken: 'JWT_FROM_YOUR_BACKEND' });

// Typed metadata flowing to other peers:
await joinRoom<MyPeerMetadata>({
  peerToken,
  peerMetadata: { displayName: 'Alice', role: 'host' },
});

JoinRoomConfig:

  • peerToken: string — required. From your backend (production) or useSandbox().getSandboxPeerToken(...) (dev).
  • peerMetadata?: PeerMetadata — optional. Visible to other peers via usePeers(). Different from the server-side metadata set in createPeer (which is immutable; this client-side one can be updated later via useUpdatePeerMetadata).

Throws if fishjamId is missing from the provider.

leaveRoom()

leaveRoom();

Disconnects. Devices stay initialized — you can joinRoom again without re-initializing.

peerStatus

Current peer connection state. PeerStatus is one of (from @fishjam-cloud/react-client):

  • 'idle' — not connected
  • 'connecting'
  • 'connected'
  • 'error' — connection failed (auth failure, network, etc.); inspect underlying client events for the reason
if (peerStatus === 'connected') ...
if (peerStatus === 'error') {
  // connection failed — likely a bad/expired token or network issue.
  // Listen on the underlying client (`fishjamClient` prop) for granular reasons.
}

reconnectionStatus

Status of the SDK's auto-reconnect attempts:

  • 'idle'
  • 'reconnecting'
  • 'idle' again after success
  • 'error' after maxAttempts exhausted

Drive UI off this — e.g. show a "Reconnecting…" banner while reconnectionStatus === 'reconnecting'.

Error reasons

Connection failures surface as peerStatus === 'error'. The reason is delivered via internal events; import the union types:

import type { AuthErrorReason, JoinErrorReason } from '@fishjam-cloud/react-client';

// AuthErrorReason: auth-time failure reasons (token expired/invalid, room not found, ...)
// JoinErrorReason: connection-time errors

(Listen via the underlying FishjamClient events — authError, joinError, etc. — if you need granular handling. See ts-client-escape.md.)

useSandbox (dev only)

For prototyping a frontend before you've stood up a backend. Calls Fishjam's no-auth Sandbox API. Never ship this in production.

Source: @fishjam-cloud/react-client → packages/react-client/src/hooks/useSandbox.ts.

import { useSandbox } from '@fishjam-cloud/react-client';

const {
  getSandboxPeerToken,
  getSandboxViewerToken,
  getSandboxLivestream,
} = useSandbox({ sandboxApiUrl: import.meta.env.VITE_SANDBOX_API_URL });

getSandboxPeerToken(roomName, peerName, roomType?)

const peerToken = await getSandboxPeerToken('test-room', 'alice');
const peerToken = await getSandboxPeerToken('voice-room', 'alice', 'audio_only');
const peerToken = await getSandboxPeerToken('stream-room', 'alice', 'livestream');

await joinRoom({ peerToken });

roomType: 'conference' | 'livestream' | 'audio_only' — defaults to 'conference'.

getSandboxViewerToken(roomName)

For private livestream rooms — issue a viewer token:

const viewerToken = await getSandboxViewerToken('my-livestream');
const { connect } = useLivestreamViewer();
await connect({ token: viewerToken });

Throws if the livestream room doesn't exist.

getSandboxLivestream(roomName, isPublic?)

Creates a livestream room and returns the streamer token:

const { streamerToken, room } = await getSandboxLivestream('my-livestream');
// or for a public livestream:
const { streamerToken, room } = await getSandboxLivestream('my-livestream', true);

const { connect } = useLivestreamStreamer();
await connect({ token: streamerToken });

room: { id, name } lets you share the room ID with viewers (public livestreams need only the ID).

Migration off the sandbox

Replace each useSandbox call with a fetch to your own backend's /api/join-room endpoint. Detail: ../platform/sandbox-vs-production.md.

Sources

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