Reputation: 121
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
Upvotes: 2
Views: 1893
Reputation: 3740
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)
})
Upvotes: 3