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
The ID of the user whose connection relationship to manage.
Returns
The current relationship state. One of:
"none" | "pending-sent" | "pending-received" | "connected" | "declined-sent" | "declined-received".The ID of the active connection record, if one exists.
Additional metadata about the connection.
true while the initial status is being fetched.Sends a connection request to the target user. Accepts an optional message string. Only active when status is
"none" or "declined-received".Accepts an incoming connection request. Only active when status is
"pending-received".Declines an incoming connection request. Only active when status is
"pending-received".Withdraws a pending outgoing request. Only active when status is
"pending-sent".Removes an established connection. Only active when status is
"connected".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.
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.
