Skip to main content

send_message

send_message(session, id, data)

Send a custom message from server to client React components.

Messages are consumed by useShinyMessageHandler(id, handler) on the React side via the @posit/shiny-react hooks bundled in shinyreact.

Args: session: The Shiny session to send the message through. id: The message id, module-resolved like input/output ids. Must match the id argument passed to useShinyMessageHandler() in the React component. data: Any JSON-serializable data to include in the message.

Example::

@reactive.effect
async def notify():
    await shinyreact.send_message(
        session, "notification", {"text": "Hello!", "level": "info"}
    )