Does `supabase.auth.onAuthStateChange()` fire an e...
# javascript
s
Does
supabase.auth.onAuthStateChange()
fire an event every time at some point after the page initially loads? For example, if the user is already logged in and visits the page, does an event fire immediately after supabase determines this? Or do events only fire when signing in or signing out is explicitly called?
g
By observation I see SIGNED_IN every time page loads or is refreshed with the user coming from the local storage. No signIn call.
s
Thanks, good to know!
Hope to see some more details like this in the docs someday
s
@silas I'm taking notes, we will be doing some documentation improvement work and I'm keeping a tab of things users are finding difficult to do and information that is missing
b
An auth example using some kind of state management library would be nice to see, I feel like there's a lot on using JWT etc. but the client sided way I feel is missing some documentation. If this does exist already my bad lol
s
Thanks—that’s really good to hear 🥳 Also, it took a long while for me to figure out why supabase.auth.user() and supabase.auth.session() would sometimes return incorrect values when called at page load, until @User explained that those methods don’t seem to check localStorage themselves but rather reference the supabase object as-is in the moment. Some explanation on that might be helpful too