Creating a React — Firebase Context with Social media authentications.

Adao Natalino
Nov 16, 2020


Part 5 — Wrapping up!

So, if you are here, it means this series has been useful and you want to see the end, right?

If you are new, let’s recap:

Part 1:

Part 2:

Part 3:

Part 4:

So now, let’s dive into the LoginWithSocialMedia component:

This component is basically getting the StyledFirebaseAuth from the dependency we have and checking if we have a current user / token for our application (using the custom hook for the context), if yes, then we redirect to the dashboard, if not, we render the social media login component.

The StyledFirebasAuth takes 2 properties, one is the uiConfig (remember we exported this config in the firebase.js file) and the other is auth function the firebase gives us.

The flow is popup, so a new window will popup for the user to login with the options:

Because we have onAuthStateChanged connected with our context, we receive the token, it will automatically update (because we set useEffect to run every time the component has an update — no dependencies to watch) the user and redirect to the dashboard:

And that is it! We’ve finished our firebase — social media application, easy right?

I hope it you enjoyed, and I’ll see you next week with a new topic to share and discuss!



Adao Natalino

Software Engineer with a Mechanical Engineer background.