Skip to main content

Overview

useUserActions is a low-level hook that provides direct access to the Redux actions and API mutations for the current user. In most cases you should use useUser instead, which wraps useUserActions and provides a higher-level interface. Use useUserActions directly when you need to manually set or clear user state — for example, in a custom authentication flow.

Usage Example

Return Values

(user: AuthUser | null) => void
Manually sets the current user in Redux state. Validates that the user object has an id before setting — partial or empty objects are silently ignored.
() => void
Clears the current user from Redux state and resets any error.
(params: { userId: string; currentUser?: AuthUser | null } & UpdateUserParams) => Promise<AuthUser>
Calls the update user API for the project of the nearest SublayProvider and manages loading and error state. The changes go next to userId, e.g. updateUser({ userId, name, currentUser }). An update key in the input throws a SublayError before anything is sent. An update with avatarFile or bannerFile is sent as multipart/form-data, any other as JSON. Applies optimistic updates for non-file fields (location and birthdate excepted). A null field next to a file throws before anything is sent or changed. Reverts to currentUser if the request fails.
() => void
Clears any error stored in the user slice.
Prefer useUser for typical profile management. useUserActions is intended for cases where you need direct control over user state, such as custom authentication integrations.