Search code examples
databasefirebaseauthenticationfirebase-authenticationaccount

Firebase Multi-Page Signin


Hello Stackoverflow Community!

I have a pretty simple question that I am pretty sure there is an answer for!

I want to create a simple sign in system for a website, however, I am wondering whether or not I can login, and then carry over the fact that it is logged in to other pages on the site. Because once a user is logged into the site using signInWithEmailAndPassword(), and I want make sure they can navigate the full website and all of it's seperate html file pages, and stay signed in.

Can anyone please help me?

Thanks, Noah


Solution

  • Firebase Authentication is persisted between page loads. But instead of calling signInWithEmailAndPassword() on each page, you should monitor onAuthStateChanged() and then only call sign-in when there is no current user.