Hiyve Components - v1.0.0
    Preparing search index...

    Function useUserChatStream

    • Subscribe to the current user's GLOBAL chat stream — new messages across ALL of their conversations — for notification badges and toasts. handlers.onMessage fires for each arrival (each carries roomName); the stream excludes the user's own messages and reconnects automatically.

      Unlike useUserChat (which streams one active conversation), this opens a single always-on stream regardless of which conversation, if any, is open — so it works while the user is anywhere in the app. No-op when userId is falsy or no cloud client is configured.

      Handlers are read through a ref, so passing new closures each render does NOT reconnect the stream; only a change of userId does.

      Parameters

      • userId: string | null | undefined

        The authenticated user (their own conversations only)

      • handlers: {
            onError?: (error: Error) => void;
            onMessage?: (message: ChatStreamMessage) => void;
            onReconnect?: () => void;
        }

        onMessage / onError callbacks

        • OptionalonError?: (error: Error) => void
        • OptionalonMessage?: (message: ChatStreamMessage) => void
        • OptionalonReconnect?: () => void

          The stream came back after a drop, confirmed by the server. This stream replays nothing on connect, so anything sent while it was down never arrives — refetch conversations here or the unread badge stays wrong.

      Returns void