GitHub

Source

useDataChannel

The useDataChannel hook returns the ability to send and receive messages.

Import

import { useDataChannel } from "@livekit/components-react";

Remarks

There is only one data channel. Passing a topic does not open a new data channel. It is only used to filter out messages with no or a different topic.

Usage

// Send messages to all participants
const { message, send } = useDataChannel(callback);

Properties

onMessage?(msg: ReceivedDataMessage) => void

Returns

UseDataChannelReturnType;