Summary
Used to manually refresh both the user state and authentication token at any point in time. This hook is useful when you need to ensure the user’s authentication data is synchronized with the server, such as after making changes to the user’s account or when the JWT token needs to be refreshed. UnlikeuseRefreshUser, which only refreshes user data, useRefreshAuth refreshes both the user information and the JWT token, ensuring complete authentication state synchronization.
The SDK state as a whole will be maintained i.e. the sdkHasLoaded boolean on useDynamicContext will stay true. If you want to reset the whole SDK including wallets, then take a look at useReinitialize.
Usage
Return Value
Returns a callback function that:- Returns
Promise<UserProfile | undefined>when called - Refreshes both user data and JWT token from the server
- Updates the SDK state with the latest authentication information
- Throws an error if the refresh results in an invalid user state
FAQs
When exactly is the JWT updated?- The JWT is updated on every successful call. On failure, nothing is mutated, so the existing JWT remains as-is (still usable until it actually expires)
- No, there’s no client-side limit, so it would come down to general rate limits at that point.
useRefreshAuthrefreshes both user data AND the JWT token from the serveruseRefreshUseronly refreshes user data without updating the JWT token- Use
useRefreshAuthwhen you need to ensure complete authentication state synchronization - Use
useRefreshUserwhen you only need to sync user profile information