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
Returns
The current relationship state. One of:
"none" | "pending-sent" | "pending-received" | "accepted" | "declined-sent" | "declined-received". It is the connection’s status, joined with its type while pending or declined ("pending-sent": the current user sent the request), or "none" when no connection exists.The connection record seen from the current user’s side, or
null when there is none. See ConnectionRow.Sends a connection request to the target user. Takes an optional
message to send with the request: sendConnectionRequest({ message: "Hi!" }). Only active when status is "none" or "declined-received"; the server rejects a new request while a declined one exists between the two users (409 connection/request-declined), so in "declined-received" the call fails. When the server answers with an existing row (your request was already pending, or you were connected meanwhile), the state takes that row. When the other user sent you a request meanwhile (409 connection/request-received), the call fails and the state takes their request from the error body, so connectionStatus becomes "pending-received" and acceptConnectionRequest works.Accepts an incoming connection request. Only active when status is
"pending-received".Declines an incoming connection request. Only active when status is
"pending-received".Acts on the connection by user ID, whatever its state: withdraws a sent request, declines a received one, or disconnects an accepted connection. Does nothing when status is
"none", "declined-sent" or "declined-received". After declining a received request it re-reads the status, so connection holds the declined record. Useful as a generic “remove” action when the exact state doesn’t matter.The current user must be signed in. The hook performs no action if
userId matches the authenticated user’s own ID.
