Overview
useAuth is the primary authentication hook. It returns current token state and functions for all built-in auth operations: sign-up, sign-in, sign-out, password change, and manual token refresh.
Usage Example
Returns
useAuth returns an object with the following fields:
true once the SDK has attempted to restore a session from the stored refresh
token. Always check this before rendering auth-dependent UI.The current JWT access token, or
null if no user is signed in. Expires every
30 minutes; the SDK refreshes it automatically.The current JWT refresh token, or
null if no user is signed in.Manually set a refresh token in Redux state. Useful when integrating external
auth flows that hand tokens directly to the SDK.
Create a new account and sign in. Accepts a
SignUpWithEmailAndPasswordProps
object. Throws if registration fails.Parameters:email(required) — User’s email addresspassword(required) — Passwordname(optional) — Display nameusername(optional) — Unique usernameavatar(optional) — Avatar URLbio(optional) — Bio textlocation(optional) —{ latitude, longitude }birthdate(optional) — Date of birthmetadata(optional) — Public custom fieldssecureMetadata(optional) — Private custom fieldsavatarFile(optional) — Avatar image file to uploadavatarOptions(optional) — Image processing options for the avatarbannerFile(optional) — Banner image file to uploadbannerOptions(optional) — Image processing options for the banner
Sign in with an existing account. Accepts
{ email: string; password: string }.
Throws if credentials are invalid.Sign out the current account. Sends a sign-out request to the server to revoke
the refresh token family, then clears local auth state. Throws on error.
Change the password for the currently authenticated user. Accepts
{ password: string; newPassword: string }. The current password must be
correct. Throws if verification fails.Manually trigger an access token refresh using the stored refresh token.
Returns the new access token string, or
undefined if the refresh fails.
The SDK handles refresh automatically in most cases; use this only when
you need to force a refresh.
