---
name: fishjam-react-client
description: "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."
license: MIT
title: fishjam-react-client
canonical_url: https://skilld.dev/gh/software-mansion-labs/skills/react-client
last_updated: 2026-10-14T18:16:09.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [connection.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/connection.md), [custom-sources.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/custom-sources.md), [data-and-events.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/data-and-events.md), [devices.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/devices.md), [livestream.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/livestream.md), [peers-and-tracks.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/peers-and-tracks.md), [provider.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/provider.md), [simulcast-and-bandwidth.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/simulcast-and-bandwidth.md), [ts-client-escape.md](https://skilld.dev/api/skills-raw/software-mansion-labs/skills/react-client/ts-client-escape.md).
>
> If the user asked to install this Skill, run `npx skilld install software-mansion-labs/skills/react-client`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/react-client`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/software-mansion-labs/skills/react-client) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/react-client`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/react-client --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/react-client --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Fishjam React Client

`@fishjam-cloud/react-client` — Fishjam's React SDK for **browser** apps. Wrap your app in `FishjamProvider`, then use hooks to drive devices, connection, and peers.

> **Read `../platform/SKILL.md` first.** It defines what rooms, peers, tokens, and the sandbox-vs-prod model are. This skill assumes those.
>
> **For React Native, use `../react-native-client/SKILL.md` instead** — it re-exports this hook surface and adds mobile-only concerns.

## Minimal setup

```bash
npm install @fishjam-cloud/react-client
# or yarn add @fishjam-cloud/react-client
```

```tsx
import { FishjamProvider, useConnection, useSandbox } from '@fishjam-cloud/react-client';

function App() {
  return (
    <FishjamProvider fishjamId={import.meta.env.VITE_FISHJAM_ID}>
      <Room />
    </FishjamProvider>
  );
}

function Room() {
  // DEV — sandbox flow (no backend needed):
  const { getSandboxPeerToken } = useSandbox({ sandboxApiUrl: import.meta.env.VITE_SANDBOX_API_URL });
  const { joinRoom } = useConnection();

  const handleJoin = async () => {
    const peerToken = await getSandboxPeerToken('test-room', 'alice');
    await joinRoom({ peerToken });
  };

  return <button onClick={handleJoin}>Join</button>;
}
```

For **production**, replace `useSandbox` with a call to your own backend that returns a peer token (see `../platform/sandbox-vs-production.md`):

```tsx
const peerToken = await fetchPeerTokenFromYourBackend(roomName);
await joinRoom({ peerToken });
```

## Hook catalog (decision tree)

| What you need | Hook | Reference |
|---|---|---|
| Open / close the connection | `useConnection` | `connection.md` |
| Sandbox tokens for prototyping | `useSandbox` | `connection.md` |
| Camera | `useCamera` | `devices.md` |
| Microphone | `useMicrophone` | `devices.md` |
| Screen share | `useScreenShare` | `devices.md` |
| Initialize devices on app load | `useInitializeDevices` | `devices.md` |
| Render peers + their tracks | `usePeers` (returns `PeerWithTracks`) | `peers-and-tracks.md` |
| Livestream as broadcaster | `useLivestreamStreamer` | `livestream.md` |
| Livestream as viewer | `useLivestreamViewer` | `livestream.md` |
| Push a `MediaStreamTrack` you generated yourself | `useCustomSource` | `custom-sources.md` |
| Peer-to-peer messages (text chat, signals) | `useDataChannel` | `data-and-events.md` |
| Detect when a remote peer is speaking | `useVAD` | `data-and-events.md` |
| Update your peer's metadata mid-session | `useUpdatePeerMetadata` | `data-and-events.md` |
| Get WebRTC `RTCStatsReport` for debugging | `useStatistics` (from `@fishjam-cloud/react-client/debug`) | `provider.md` |
| Configure simulcast / bandwidth | (props on `FishjamProvider`) | `simulcast-and-bandwidth.md` |
| Use Fishjam from non-React code (workers, Svelte, vanilla TS) | `@fishjam-cloud/ts-client` | `ts-client-escape.md` |

## Key rules

- **One `FishjamProvider` per app.** Don't nest. It owns the `FishjamClient`, all device managers, and reconnection state.
- **`useSandbox` is dev-only.** Gate it with `if (import.meta.env.DEV)` (or equivalent) so a sandbox URL can never ship in a production bundle.
- **Browser requires user gesture for `useScreenShare`** — call inside an `onClick`, not on mount.
- **Devices stay mounted across connection state.** Initializing with `useInitializeDevices` once is enough — they remain available after you `leaveRoom`.
- **Livestream rooms have a one-track-per-direction constraint.** One video + one audio on the streamer; viewers don't publish.
- **For non-React contexts** (Svelte, Vue, workers, vanilla TS), use `@fishjam-cloud/ts-client` directly. The React SDK is a thin layer over it. See `ts-client-escape.md`.
- **The provider re-exports `Variant` from `ts-client`** for simulcast quality (`Variant.VARIANT_LOW | Variant.VARIANT_MEDIUM | Variant.VARIANT_HIGH`).

## References

| File | When to read |
|---|---|
| `provider.md` | All `FishjamProvider` props — `fishjamId`, `reconnect`, `constraints`, `persistLastDevice`, `bandwidthLimits`, `videoConfig`, `audioConfig`, `debug`, `fishjamClient`. |
| `connection.md` | `useConnection` (`joinRoom`, `leaveRoom`, `peerStatus`, `reconnectionStatus`) and `useSandbox`. |
| `devices.md` | `useCamera`, `useMicrophone`, `useScreenShare`, `useInitializeDevices`. Device enumeration, switching, persistence. |
| `peers-and-tracks.md` | `usePeers` — `localPeer`, `remotePeers`, the `PeerWithTracks` shape. |
| `livestream.md` | `useLivestreamStreamer`, `useLivestreamViewer`, public vs private flows. |
| `custom-sources.md` | `useCustomSource`, `TrackMiddleware`, `TracksMiddleware`. |
| `data-and-events.md` | `useDataChannel`, `useVAD`, `useUpdatePeerMetadata`. |
| `simulcast-and-bandwidth.md` | `Variant`, `BandwidthLimits`, `SimulcastConfig` via `videoConfig` / `audioConfig`. |
| `ts-client-escape.md` | When and how to drop to `@fishjam-cloud/ts-client`. |
