Firebase for Login and Logout — Part 2

Grishma
1 min readOct 4, 2022

--

For installing and setting up firebase into your react app, open terminal/command prompt and install firebase using npm install or yarn add. Then copy-paste the code given in SKD into your code to add and initiate an instance of firebase for your app.

To setup authentication, we need to import required functions from firebase/auth. To create an instance of auth we need to import getAuth. For creating SignIn, import signInWithPopup. For implementing google signin, import GoogleAuthProvider.

Initialize a provider using GoogleAuthProvider and set required custom parameters. Then create instance of auth and define a signin function.

For integrating with UI, we create a button which onClick will call the signin function and allow us to signin with Google.

To install and instantiate firestore, we need to import it into our app alongwith doc and functions to read and update doc (i.e. getDoc & setDoc)

--

--