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.null
if 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.
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:
-
getProfile(userId: string): Promise<Profile | null>
Fetches the profile of a given user by ID. -
updateProfile(data: Partial<Profile>): Promise<Profile>
Updates the current user’s profile with the provided data. -
searchProfiles(query: string): Promise<Profile[]>
Searches for profiles based on a query (e.g., username or email).
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 ifuserId
is 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.