why onAuthStateChange make function loop
# help-and-questions
j
Hello there! Basically, I want to save my login user data to my database, but here's the issue: when I put supabase.auth.onAuthStateChange on my next page/_app.js, it makes it loop and ratelimit my database API.
Copy code
js
    supabase.auth.onAuthStateChange(async (event) => {
      if (!event) return;
      if (event === 'SIGNED_IN') {
        console.log('User signed in'); //this span in console multiple times
      } else return
    });