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

Parameters

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

Returns

A Promise<ConnectionRow> that resolves to the connection, seen from the signed-in user’s side. See ConnectionRow.
  • A new request resolves to the new pending row.
  • When the signed-in user’s own request is still pending, or the two are already connected, it resolves to that existing row, so a repeat is safe. The stored message is kept and no second notification is sent.
  • When the other user already sent the signed-in user a request, it rejects with 409 connection/request-received. The error body carries their request as connection, so you can offer to accept it.
  • After the other user declined the signed-in user’s request, it rejects with 409 connection/request-declined.
string
The connection’s ID. Accept, decline and remove take it.
User
The user the request was sent to. Public profile fields only.
"sent" | "received"
"sent" when the signed-in user sent the request (always, for a new one); "received" for an existing accepted connection the other user started.
string | null
The note sent with the request, or null.
"pending" | "accepted" | "declined"
"pending" until the receiver responds.
string
ISO timestamp of when the request was sent.
string | null
When the request was accepted; null while it is pending.