Listen to auth events
Receive a notification every time an auth event happens.
- Types of auth events:
SIGNED_IN
,SIGNED_OUT
,TOKEN_REFRESHED
,USER_UPDATED
,PASSWORD_RECOVERY
- Currently,
onAuthStateChange()
does not work across tabs. For instance, in the case of a password reset flow, the original tab which requested for the password reset link will not receive theSIGNED_IN
andPASSWORD_RECOVERY
event when the user clicks on the link.
Parameters
- callbackREQUIREDfunction
A callback function to be invoked when an auth event happens.
supabase.auth.onAuthStateChange((event, session) => {
console.log(event, session)
})