Phonelink

phonelink/web

API reference for the Phonelink web client.

Exports

The phonelink/web entry point exports the following:

ExportTypeDescription
phonelinkobjectWeb client with verify and getResult methods
usePhonelinkfunctionReact hook for the full verification flow
PhonelinkPayloadtypeTypeScript type for the decoded JWT payload

phonelink.verify(clientId, callbackUrl)

Starts the phone verification flow by redirecting to Phonelink.

ParameterTypeDescription
clientIdstringYour Phonelink client ID
callbackUrlstringURL to redirect back to after verification

Returns: void

Generates a 32-byte cryptographic nonce, stores it in sessionStorage under the key phonelink_nonce, and redirects the browser to https://phone.link/auth with the client ID, callback URL, and nonce as query parameters.


phonelink.getResult()

Reads the verification result on the callback page.

Parameters: none

Returns: { token: string; nonce: string } | null

Extracts the token from the URL query parameters and retrieves the nonce from sessionStorage. Removes the nonce from storage after retrieval. Returns null if no token is found in the URL or if the nonce is missing from storage.


usePhonelink(options)

React hook that manages the full verification flow.

Options

PropertyTypeDescription
clientIdstringYour Phonelink client ID
callbackUrlstringURL to redirect back to after verification

Return value

PropertyTypeDescription
verify() => voidInitiates the verification flow
result{ token: string; nonce: string } | nullVerification result, or null
isCallbackbooleanWhether the current page is the callback page

On mount, the hook calls getResult() to check for a token in the URL. If found, result is populated and isCallback is true. The verify function is memoized with useCallback and only changes when clientId or callbackUrl change.


PhonelinkPayload

TypeScript interface for the decoded JWT payload. See Server API Reference for the full property list.

import type { PhonelinkPayload } from "phonelink/web";

On this page