2

I'm struggling to implement an idea. If a user is logged in, I want to show a hidden div.

For example in firebase I can do this:

firebase.auth.signInAnonymessly()

// Detecting if the auth state changed
firebase.auth.onAuthStateChanged((user) => {
  // If a user exists show him a hidden div
  if(user) {
    HiddenDiv.style.display = block
  }
})

I want to do this but in supabase

I searched the supabase docs and didn't find anything pls help

Felix Eklöf
  • 3,253
  • 2
  • 10
  • 27

1 Answers1

3

There's a method in Supabase that works in almost the same way as Firebases' onAuthStateChange, here's a reference to the docs.

supabase.auth.onAuthStateChange((event, session) => {
  console.log(event, session)
})
Felix Eklöf
  • 3,253
  • 2
  • 10
  • 27