Shinigami Hooks


The useDataMessage hook allows you to send and receive messages to and from other peers in the room.

const {
  } = useDataMessage({
    onMessage(payload, from, label) {},


The useDataMessage hook accepts an object with the following fields as props.

1. onMessageOptional
DescriptionReturn Type
This function will be called when you receive a data message from any other peer in the room.void
Parameter NameTypeDescriptionRequired
payloadstringThe message string.Yes
fromstringThe peerId of the sender.Yes
labelstringAn optional label field for the message.No
Example Usage
const dataMessage = useDataMessage({ onMessage: (payload, from, label) => {
	console.log("Received a message!");
	console.log("Message: ", payload);
    console.log("Sender: ", from);
    if(label) console.log("Label: ", label);
    // your code here


The useDataMessage hook returns an object with the following fields.

1. sendDataFunction
DescriptionReturn Type
Send a message to other peers in the room.Promise<Room>
Parameter NameTypeDescriptionRequired
data{ to: string[] | "*"; payload: string; }Object containing the message to be sent (payload) and an array of peerIds to send the message to (you can use a "*" to denote all peers in the room).Yes
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
Copyright © 2022 Graphene 01, Inc. All Rights Reserved.