Overview
Manages the typing indicator for a conversation. Returns the list of user IDs currently typing (for rendering a “Someone is typing…” indicator) andstartTyping/stopTyping functions that emit the appropriate socket events.
Requires
ChatProvider in the component tree.Usage Example
Props
The ID of the conversation to track typing state for.
Returns
Array of user IDs currently typing in this conversation. The current user is always excluded.
Emits a
typing:start event to the server. Throttled internally — safe to call on every keystroke. Re-emits the keep-alive every 2 seconds while typing continues.Emits a
typing:stop event to the server and cancels the keep-alive interval. Call on message send, input clear, or blur.Notes
startTyping()is idempotent while already typing — calling it repeatedly does not emit duplicate events; only the keep-alive timer re-emits every 2 seconds.- On unmount, if the user was typing,
typing:stopis emitted automatically to prevent a stale indicator on recipients’ screens. - Each typing user is auto-removed from
typingUsersafter 5 seconds of no keep-alive (handled byChatProvider). - For integration guidance, see Chat: Real-time.

