I'm using onAuthStateChange and when i change auth...
# help
k
I'm using onAuthStateChange and when i change auth state it seems like this function runs several times. How can i avoid this?
This is the whole code including client initializing. Could it be that multiple clients gets initialized or something?
g
I believe it all depends on where you are calling useSupabase. If it gets called multiple times I believe you will have multiple listeners.
j
Yea looks like you’ll end up with a listener every time you use useSupabase() There is an example of using onAuthStateChange using react provider in our NextJS auth example which might be better for this
k
Thanks @User I'll look into this!