Skip to main content
useConnectionManager is the recommended way to implement connection UIs. It loads the connection status with a specific user on mount and exposes named actions for every state transition: send, accept, decline, withdraw, and disconnect.

Usage Example

Parameters

userId
string
required
The ID of the user whose connection relationship to manage.

Returns

connectionStatus
ConnectionStatus
The current relationship state. One of: "none" | "pending-sent" | "pending-received" | "connected" | "declined-sent" | "declined-received".
connectionId
string | null
The ID of the active connection record, if one exists.
connectionData
object
Additional metadata about the connection.
isLoading
boolean
true while the initial status is being fetched.
sendConnectionRequest
(message?: string) => Promise<void>
Sends a connection request to the target user. Accepts an optional message string. Only active when status is "none" or "declined-received".
acceptConnectionRequest
() => Promise<void>
Accepts an incoming connection request. Only active when status is "pending-received".
declineConnectionRequest
() => Promise<void>
Declines an incoming connection request. Only active when status is "pending-received".
withdrawConnectionRequest
() => Promise<void>
Withdraws a pending outgoing request. Only active when status is "pending-sent".
disconnectUser
() => Promise<void>
Removes an established connection. Only active when status is "connected".
removeConnectionSmart
() => Promise<void>
Removes the connection regardless of current state (withdraw, decline, or disconnect) by user ID. Useful as a generic “remove” action when the exact state doesn’t matter.
refreshConnectionStatus
() => Promise<void>
Re-fetches the connection status from the server.
The current user must be signed in. The hook performs no action if userId matches the authenticated user’s own ID.