Skip to main content

Overview

Returns a function that removes a connection with another user by their userId, 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:
string
required
The ID of the user to disconnect from. Cannot be the current user’s own ID.

Returns

A Promise<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.