User Login
Once you’ve initialized the SDK withOfflineAppProvider, you can use the useAuth hook anywhere in your app to handle user authentication.
You can import and use the hook in any component:
useAuth hook gives you access to:
-
sendCode(email: string): Promise<boolean>
Sends a one-time password (OTP) to the provided email for login. -
verifyCode(email: string, otp: string): Promise<UserAccount | null>
Verifies the OTP and, if successful, logs in the user and stores their session. -
user: UserAccount | null
The currently authenticated user.nullif no user is logged in. -
logout(): void
Clears the current session and removes authentication data from storage. -
refreshUser(): Promise<void>
Fetches the latest user information from the API. -
registerUsername(username: string): Promise<Profile | null>
Registers a username for the logged-in user. -
isUsernameAvailable(username: string): Promise<boolean>
Checks if a username is available for registration. -
loginWithModal(): Promise<void>
Opens the login modal dialog for user authentication.
Profiles
TheuseProfiles hook allows you to manage and fetch user profiles within your app.
You can import and use the hook in any component:
useProfiles hook gives you access to:
-
profiles
Array of user profiles available in the system. -
profileCount
Total count of profiles in the system. -
searchProfile(query: string): Promise<string[]>
Promise that resolves to an array of matching profile identifiers or usernames.
Connections
Once you’ve initialized the SDK withOfflineAppProvider, you can use the useAuth hook anywhere in your app to handle user authentication.
You can import and use the hook in any component:
useConnections hook gives you access to:
-
getConnections(userId?: string): Promise<Connection[]>
Fetches the list of connections for the logged-in user, or for another user ifuserIdis provided. -
addConnection(username: string): Promise<boolean>
Sends or accepts a connection request with the specified user. -
removeConnection(username: string): Promise<boolean>
Removes an existing connection. -
isConnected(username: string): Promise<boolean>
Checks if the logged-in user is already connected to the specified user.