Skip to main content

useDeclineConnection

Overview

The useDeclineConnection hook allows the current logged-in user to decline an incoming connection request. This permanently rejects the connection request and notifies the requester that their request was declined.

Usage Example

Advanced Usage with Confirmation

Usage in Connection Request Management

Usage with Decline Reasons

Parameters & Returns

Parameters

The hook returns a function that accepts an object with the following field:
connectionId
string
required
The ID of the connection request to decline

Returns

The function returns a Promise that resolves to a ConnectionActionResponse object containing:
id
string
The ID of the connection request
respondedAt
string
ISO date string of when the request was declined

Error Handling

The hook will throw errors in the following cases:
  • No project is specified
  • No user is logged in
  • No connection ID is provided
  • Connection request doesn’t exist or has already been processed
  • Network connection issues

Best Practices

  1. Always confirm - Show a confirmation dialog before declining connections
  2. Provide feedback - Let users know the action was successful
  3. Handle errors gracefully - Show user-friendly error messages
  4. Consider reasons - Optionally collect decline reasons for analytics
  5. Update UI state - Remove declined requests from the UI immediately

Use Cases

This hook is commonly used in:
  • Connection request notification interfaces
  • Professional networking platforms
  • Social platform connection management
  • Mobile app notification handlers
  • User inbox/messages systems
  • useAcceptConnection - Accept connection requests
  • useRequestConnection - Send new connection requests
  • useFetchReceivedPendingConnections - Get pending connection requests
  • useConnectionManager - Comprehensive connection state management