useAppMessage

useAppMessage({ onAppMessage?: Function}) : Object

Convenience hook for the daily-js sendAppMessage() method.

useAppMessage can also set up an optional callback for the app-message event.

Params (optional)

An object with the following properties:

  • onAppMessage (optional): Function, callback for the app-message event. When an app-message is sent, the callback will be called with two arguments:
NameTypeDescription
evObjectThe original event payload sent from daily-js
sendAppMessageFunctionThe function reference that was created internally inside useAppMessage. This avoids having to call the hook twice in order to respond to an app-message with an app-message

Return type

NameTypeDescription
sendAppMessageFunctionSee sendAppMessage() instance method in daily-js

Sample code