> ## Documentation Index
> Fetch the complete documentation index at: https://docs.replyke.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove connection by user ID

> Remove a connection with a user by their user ID

## Overview

Returns a function that removes a connection with another user by their `userId`, without needing the connection record ID. The server determines the correct action (withdraw, disconnect, or decline) based on the current state. The current user must be authenticated.

<Note>
  This hook is used internally by `useConnectionManager`'s `removeConnectionSmart` function.
</Note>

## Usage Example

```tsx theme={null}
import { useRemoveConnectionByUserId } from "@replyke/react-js";

function RemoveButton({ userId }: { userId: string }) {
  const removeConnectionByUserId = useRemoveConnectionByUserId();

  return (
    <button onClick={() => removeConnectionByUserId({ userId })}>
      Remove Connection
    </button>
  );
}
```

## Parameters

The hook returns a function. That function accepts:

<ParamField path="userId" type="string" required>
  The ID of the user to disconnect from. Cannot be the current user's own ID.
</ParamField>

## Returns

<ResponseField name="id" type="string | undefined">
  The connection record ID, if applicable.
</ResponseField>

<ResponseField name="action" type="&#x22;withdraw&#x22; | &#x22;disconnect&#x22; | &#x22;decline&#x22; | undefined">
  The action performed by the server.
</ResponseField>

<ResponseField name="message" type="string | undefined">
  A confirmation message.
</ResponseField>

## Related

* [useRemoveConnection](/hooks/connections/use-remove-connection) — remove by connection ID
* [useConnectionManager](/hooks/connections/use-connection-manager) — wraps this as `removeConnectionSmart`
