The best way to start your React Native application with Firebase authentication.
Works both with expo and react-native init.
All screens are made only with native components.
Folder FirebaseLogin contains:
- Login screen
- Register screen
- Forgot password screen
- Download FirebaseLogin from this repo.
- Add firebase module to your project:
npm i -s firebase
- Configure your application with firebase. You can find some information here.
Basically all you have to do is to add config file in your main application file and initialize firebase.
Your code should look like this:
import firebase from "firebase";
const config = {
apiKey: "xyz",
authDomain: "xyz",
databaseURL: "xyz",
projectId: "xyz",
storageBucket: "xyz",
messagingSenderId: "xyz"
};
firebase.initializeApp(config);
- Copy/Paste FirebaseLogin and put it in your project.
- Import FirebaseLogin component and put it in you render method.
Make sure you reserved whole screen for this component!
import FirebaseLogin from "./FirebaseLogin";
render() {
retrun (
<FirebaseLogin login={user => console.warn(user)}/>
)
}
Component comes with few props:
<FirebaseLogin
login={user => console.warn(user)}
background={path_to_your_background_image}
/>
Login - this props will be invoked when user successfully log in. In return you receive basic information about user.
Background - path to image you want to use as background.
I hope this module will save you several hours of work ;)
In case of any problems or suggestions you can email me at: tomasz.przybyl.it@gmail.com
Happy Coding!