Titanium
Titanium

Reputation: 51

React Native Auth with Google and Firebase

I am new to react-native, I use expo-client (managed workflow) for react native, and my app only has google sign-in. After authentication, I want to be able to store the user details on Firebase. How can I do that?

Upvotes: 0

Views: 248

Answers (1)

fadzb
fadzb

Reputation: 459

I would suggest starting off by learning how to use basic forms in React Native.

I like the native-base forms: https://docs.nativebase.io/Components.html#Form (but you can use whichever library you prefer, or even build the components from scratch)

These form components will need to hold some simple state i.e. username and password (learn how state works in react): https://reactjs.org/docs/state-and-lifecycle.html#adding-local-state-to-a-class

Social handles and Google-signins are not so straightforward. There are components that might make it easier (https://github.com/react-native-community/google-signin) but I suggest building a simple username/password sign in form first.

Once you collect the username and password, Firebase offer a pretty easy to use authentication API that is very well documented (https://firebase.google.com/docs/auth).

I have built a react-native app recently and my API calls (register/login/signout) to Firebase can be found here https://github.com/fadzb/DiaLog/blob/master/src/utils/FirebaseAuth/AuthUtils.ts

To conclude, I suggest learning all the basics first! React components/lifecycle, state, props, callbacks etc. And then learning how to integrate these components with a mobile backend as a service (MbaaS) such as Firebase which provides some nice APIs and Database utility for quick startup apps. I hope this helps!

Upvotes: 1

Related Questions