Skip to main content

useRemoveConnectionByUserId

Overview

The useRemoveConnectionByUserId hook allows the current logged-in user to remove a connection or withdraw a connection request using a user ID instead of a connection ID. This is a convenience hook that automatically finds and removes any connection relationship with the specified user.

Usage Example

Advanced Usage with Confirmation

Usage in Connection Management

Bulk Removal by User IDs

Usage with Error Recovery

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following field:
userId
string
required
The ID of the user to remove connection with

Returns

The function returns a Promise that resolves to a RemoveConnectionByUserIdResponse object containing details about the removal operation.

Error Handling

The hook will throw errors in the following cases:
  • No project is specified
  • No user is logged in
  • No user ID is provided
  • Attempting to remove connection with yourself
  • No connection exists with the specified user
  • Network connection issues

Advantages over useRemoveConnection

Convenience:
  • No need to know the specific connection ID
  • Works with just a user ID (simpler API)
  • Automatically handles different connection states
Flexibility:
  • Works for established connections, pending requests, and declined requests
  • Single API for all connection removal scenarios
User Experience:
  • Simpler integration in user-facing components
  • More intuitive for developers building UI components

Use Cases

This hook is ideal for:
  • User profile connection management
  • “Block” or “Remove” functionality in user lists
  • Cleanup operations when users are removed
  • Privacy controls and connection management
  • Administrative user management interfaces
  • useRemoveConnection - Remove connection by connection ID
  • useFetchConnectionStatus - Check connection status before removal
  • useConnectionManager - Comprehensive connection state management
  • useRequestConnection - Send new connection requests after removal