Template starter with React Navigation and Firebase auth using React Context
# Preview
![../media/authflow.png](../media/authflow.png)
# Installation
1. Install [node.js](https://nodejs.org/en/)
2. Install Expo
```jsx
npminstall--globalexpo-cli
```
3. Download this repo
4. Install deps on your template folder
```jsx
npminstall
```
5. Start the environtment
```jsx
expostart
```
# Auth Flow
### Firebase Setup
- Set up a new firebase project
- Go to Authentication and under Sign-in Method enable Email/Password
- Fill this firebase config to your config inside `./src/navigation/AppNavigator.js`
```jsx
// Better put your these secret keys in .env file
constfirebaseConfig={
apiKey:'',
authDomain:'',
databaseURL:'',
projectId:'',
storageBucket:'',
messagingSenderId:'',
appId:'',
};
```
### Prebuilt UI Screens
There are 3 screens included inside `./src/screens/auth` and one more thing its included with the firebase auth function, so you don't need to create the function. The ilustrations I use [undraw](https://undraw.co/)
I personally use these screens on my project [TiktTeng](https://github.com/codingki/TikTeng) in early stages before the redesign, feel free to use these screens ❤️
### React Navigation Auth Flow
The checking logged users process is inside `./src/provider/AuthProvider` I use React Context, you can add more functions like get the data of the user and store it to the context (better static data, ex: uid)
Inside the navigator `./src/navigation/AppNavigator.js`
There's 2 stack navigator :
-`<Auth/>` → for not logged in users stack
-`<Main/>` → for logged in users stack
-`<Loading/>` → when checking if the user is logged in or not loading screen
```jsx
exportdefault()=>{
constauth=useContext(AuthContext);
constuser=auth.user;
return(
<NavigationContainer>
{user==null&&<Loading/>}
{user==false&&<Auth/>}
{user==true&&<Main/>}
</NavigationContainer>
);
};
```
## Rapi UI
![../media/hero.png](../media/hero.png)
These UI components are provided by [Rapi UI](https://rapi-ui.kikiding.space/).
Check the [documentation](https://rapi-ui.kikiding.space/docs/) for usage and more components.
# File Managements
These are the folders and the functionality
```jsx
/src/assets->formediasuchasimages,etc
/src/components->forcomponents
/src/navigation->forReactNavigation
/src/provider->forReactContext
/src/screens->forScreens
```
if you find these useful don't forget to give it a star ⭐ and share it to your friends ❤️
Reach me on [twitter](https://twitter.com/kikiding/)