useAuth hook exposes all the actions you need.
Sign Up
CallsignUpWithEmailAndPassword with at minimum an email and password. Additional profile fields are optional.
Optional Profile Fields
You can pass additional profile data at registration time:If you supply both
avatar (URL) and avatarFile (file upload), the file
takes precedence and the URL is ignored.Sign In
The Account Limit
A device stores at most 5 accounts (Multi-Account). Both calls above refuse a sixth, throwing anError whose message is exported as ACCOUNT_LIMIT_MESSAGE:
Sign-in is deliberately checked after the network call. Comparing the typed email against the stored accounts first would be faster and wrong: it would refuse users whose stored email is out of date, absent, or capitalised differently, with no way through.
accountLimitReached — see Reaching the account limit.
Sign Out
signOut revokes the current session’s entire token family on the server and clears local auth state. Once this device has a stored push identifier it also asks the server to unbind that account’s push notifications, in the same transaction as the session teardown.
signOut rejects when the server refuses that unbind, and in that case nothing was torn down on either side — the session survives so the user can retry. Its signature is () => Promise<void>, so nothing warns you at compile time; without the catch the rejection is unhandled and your UI reports a sign-out that did not happen. Every other failure — no network, a throttled or otherwise rejected request, a device that never registered for push — still signs out locally, because a user must always be able to sign out. See useAuth.
Change Password
Users who signed up with email/password can change their password while authenticated. The current password must be provided for verification. A password change ends every other session for that user, so their other devices must sign in again with the new password. The session making the call survives — the server reads which session is asking off the access token the request already carries, so nothing extra is sent. It also removes that user’s push bindings on every other device while keeping this one’s, which the hook arranges by sending the device identifier it already holds. SeeuseAuth and Change Password.
Password Reset
Users who forget their password can request a reset email. Sublay sends a link to the registered email address. The link expires after 1 hour. Completing the reset revokes every session for that user and removes every push binding they hold, on every device — including the one they are standing on. They sign in again everywhere, and each device re-binds for push on its own once it is next opened. The reset itself is completed by the page the link points to, which collects the new password and calls the Reset Password endpoint — there is no React hook for that step.The API always responds with a success message regardless of whether the email
address is registered, to prevent user enumeration.
Auth State
Check whether the SDK has finished initializing and whether a user is currently signed in:Email Verification
After sign-up, you can prompt users to verify their email address. Sublay sends a short-lived token (5 minutes) via email. There are two delivery modes: a code the user types back into your app, or a link they click to verify automatically.Send a verification email
mode is always required, and it determines what else you need to pass:
TypeScript enforces this combination at compile time —
sendVerificationEmail({ mode: "code" }) or sendVerificationEmail({ mode: "code", tokenFormat: "numeric" }) (missing tokenLength) won’t type-check.
Verify with a code
When usingmode: "code", collect the token from the user and call useVerifyEmail:
user.isVerified is updated immediately in the local Redux store — no refetch needed.
Link mode
When usingmode: "link", the email contains a button the user clicks. The server verifies the token and either:
- Redirects to the
redirectUrlyou provided with?verified=trueappended, or - Renders a hosted success page if no
redirectUrlwas given.
user.isVerified field will be true the next time the user’s session is loaded (e.g. on next sign-in or token refresh). There is no SDK callback for link-mode verification since it happens outside the app’s JS context.
The verification token is valid for 5 minutes and can only be used once.
Calling
sendVerificationEmail while a previous token is still valid will
generate a new token — the old one remains valid until it expires or the new
one is used.
