Skip to main content

Overview

Returns a function that fetches the paginated list of accepted connections for any user, identified by userId. This is a public endpoint — authentication is not required. For fetching your own connections, see useFetchConnections.

Usage Example

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

function UserConnections({ userId }: { userId: string }) {
  const fetchConnectionsByUserId = useFetchConnectionsByUserId();
  const [connections, setConnections] = useState([]);

  useEffect(() => {
    fetchConnectionsByUserId({ userId, page: 1 }).then((res) => {
      setConnections(res.data);
    });
  }, [userId]);

  return (
    <ul>
      {connections.map(({ id, connectedUser }) => (
        <li key={id}>{connectedUser.name}</li>
      ))}
    </ul>
  );
}

Parameters

The hook returns a function. That function accepts:
userId
string
required
The ID of the user whose connections to fetch.
page
number
Page number to fetch. Defaults to 1.
limit
number
Number of results per page. Defaults to 20.

Returns

Returns a PaginatedResponse containing an array of established connections:
data
EstablishedConnection[]
Array of accepted connection entries.
pagination
object
Pagination metadata including page, pageSize, totalPages, totalItems, and hasMore.