useWebSocketStatus
Read a client's connection status. Re-renders only when the status changes.
Usage
Parameters
Returns
A Status: 'idle', 'connecting', 'open', 'reconnecting' or 'closed'.
Behavior
- Status only. Messages and
attemptchanges don't re-render. UseuseWebSocket(client)if you also needattemptorlastMessage. - Holds the connection. While mounted, the component keeps the client connected.
- Server rendering. Returns
'idle'on the server and during hydration.