React Native: Firebase Email Authenticaton in an Expo Project

React Native: Firebase Email Authenticaton in an Expo Project

On my journey on learning App development with React Native, i decide to try making a small and contained app that will service a unique…

How this app works

Basically, the app is composed of 3 screens in two navigation stacks. A stack holding the sign in and signup (not yet implemented) screens, a stack holding the home screen for logged in user. The app is started with a isLoading state active and a userLogged state to false; it will show a page loader, during this time with useEffect we will check the Firebase user state:

Firebase.auth().onAuthStateChanged((user) => {…})

if it changes and returns a user, then we set the isLoading to false and userLogged to true or false, based on the user object presence. The combination of these two values, allow us to show the correct stack.

If the user is logged the stack shows up with the home screen (that actually holds just a button to sign out and a button to switch theme), if the user is not logged it shows with a login screen that also has a link to sign up screen.

I built this project for future implementation in bigger apps that requires user login. This app also lacks error messages for wrong credentials and other things that could be easily implemented (code is commented)

Prerequisites

Before start coding I created a new project on Firebase (https://console.firebase.google.com/) and added Authentication Service, I selected Email/Password as Sign-in method, I also created a test user:

Image for post

Then I copied the Firebase configuration from the project settings (gear icon on top left)

Image for post

react javascript react-native firebase

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms? React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. **[Hire...

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

React Native Redux | How To Use Redux In React Native

React Native Redux Example Tutorial From Scratch. We connect the React Native app to Redux store to save and retrieve the application data.

Build a simple React Native Pokemon app with React-Navigation

As we start learning new technologies we want to start building something or work on a simple project to get a better understanding of the technology.