onAuthStateChange fires twice. Is this normal?
I've read through the docs and it's not clear.
For some reason, onAuthStateChange fires twice! This is problematic because once a user is authenticated, I want to fetch their profile (based on their user id) with the SIGNED_IN action. Since it fires twice, it will make a fetch twice and update my Pinia store twice.
Is this normal? I suspected it may be firing on SSR and then client but both appear to be on the client side, so I'm not sure why this happens.
I'm looking for some clarification on the matter, whether this is expected and what can be done about a situation like this?
I'm using the composables in the most simple way possible:
const supabaseAuthClient = useSupabaseAuthClient()
supabaseAuthClient.auth.onAuthStateChange(async (action, session) => {
console.log(action, session) // logs twice!
})
@michaelpumo I have tested this in my project but it fires only once, Maybe if you share more details, we can help.