Api referenceReact
useConnectionStatus
Returns the current WebSocket connection status.
Signature
Returns
One of: "connecting", "connected", "disconnected", "reconnecting", "error".
Re-renders
The hook re-renders whenever the connection status changes.
Usage
Reconnection
When the WebSocket drops unexpectedly, Flock automatically tries to reconnect with exponential backoff. During this period the status is "reconnecting". Once reconnected it returns to "connected" and all room state resumes.
If reconnect attempts are exhausted (when reconnect.maxAttempts is set), the status becomes "error".
Requirements
Must be called inside a <FlockProvider>. Throws if used outside one.