I'm using onAuthStateChange and when i change auth state it seems like this function runs several times. How can i avoid this?
kenta37
11/13/2021, 12:24 AM
This is the whole code including client initializing. Could it be that multiple clients gets initialized or something?
g
garyaustin
11/13/2021, 12:27 AM
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
jonny
11/13/2021, 5:31 AM
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