Overview
Returns a function that removes a connection with another user by theiruserId, without needing the connection record ID. The server picks the action from the current state. The current user must be authenticated.
- Pending, sent by the current user — withdraws the request (the record is deleted).
- Pending, sent by the other user — declines the request (the record stays, with
status: "declined"). - Accepted — disconnects both users (the record is deleted).
This hook is used internally by
useConnectionManager’s removeConnectionSmart function.Usage Example
Parameters
The hook returns a function. That function accepts:Returns
APromise<void>. It resolves with no value once the server has acted (it answers 204 No Content), and rejects if the request fails. To read the resulting state — for example the declined request — call useFetchConnectionStatus.
Related
- useRemoveConnection — remove by connection ID
- useConnectionManager — wraps this as
removeConnectionSmart

