Invalidate useSession()?

I'm using authClient.updateUser() to update user's name, but I want to make sure the new name is reflected in the useSession return value before performing a url change. Any way to make sure of that? Anything like Tanstack Query's .invalidateQueries()? I see there's refetch() on useSession() but it doesn't return a promise for me to make sure the refetch is completed.
3 Replies
bekacru
bekacru3w ago
The updateUser should trigger refetch itself
bekacru
bekacru3w ago
if you need a more granular refetch and trigger patterns for session, I'd recommend using tanstack query + calling getSession directly or using this library which provides tanstack implementation of use session https://github.com/daveyplate/better-auth-tanstack
GitHub
GitHub - daveyplate/better-auth-tanstack
Contribute to daveyplate/better-auth-tanstack development by creating an account on GitHub.
Ali
AliOP3w ago
Ah yeah that sounds like what I need. Thanks a lot! Also thank you for making better auth 🙏 loving it so far

Did you find this page helpful?