Skip to main content

Overview

Returns a function that sends a connection request to another user. An optional message can be included with the request. The current user must be authenticated.

Usage Example

import { useRequestConnection } from "@replyke/react-js";

function ConnectButton({ userId }: { userId: string }) {
  const requestConnection = useRequestConnection();

  const handleConnect = async () => {
    const result = await requestConnection({ userId, message: "Let's connect!" });
    console.log("Request sent:", result.id);
  };

  return <button onClick={handleConnect}>Connect</button>;
}

Parameters

The hook returns a function. That function accepts:
userId
string
required
The ID of the user to send a connection request to.
message
string
An optional message to include with the connection request.

Returns

id
string
The ID of the newly created connection record.
status
string
The status of the connection, e.g. "pending".
createdAt
string | undefined
ISO timestamp when the request was created.