In order for you to run this project. npm install or yarn install
Expo Firebase Doc: https://docs.expo.dev/guides/using-firebase/
- You will need to first create a project inside of Google's Firebase. https://firebase.google.com/
• Note: Do not use your school email. If you can create a Gmail account. - Go to the Dashboard of your Firebase account and click the Add Project button. Follow the directions. Accept the defaults if you want you can add analytics.
- Next, click on the authentication button in the left-hand menu, then click on sign-in method and make sure you enable email and password.
- Depending on the database, you want to use, click on build, and then either firestore or real-time database. We will be using firestore, so make sure you enable that and then set the permissions to test mode.
- Next go to this page, How to Create a React Native Project Locally, and create your local Expo project.
- After you create the project you will need to install the following packages.
- npx expo install firebase
npx expo install firebase
- npx expo install firebase
- Next copy your config file from your project at firebase.google.com. Something that looks like this.
// Import the functions you need from the SDKs you need import { initializeApp } from "firebase/app"; import { getAnalytics } from "firebase/analytics"; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration // For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "", authDomain: "", databaseURL: "", projectId: "", storageBucket: "", messagingSenderId: "", appId: "", measurementId: "" };
// Initialize Firebase const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app);
- Now create a file in the root of your project called, firebaseConfig.js
and paste the code you copied from the firebase website into the file. - Next, you need to import auth from firebase/auth
import { getAuth } from "firebase/auth";
- Now that you have auth imported, we need to export it so other components can use it. Place this at the bottom of the file under the const app.
export const auth = getAuth(app);
- Now we need to bring in Firestore. Import Firestore and make it accessible.
import { getFirestore } from "firebase/firestore";
// put the below line at the bottom of the file export const firestore = getFirestore(app); - Then run npx expo customize metro.config.js
npx expo customize metro.config.js
- Then put this in the metro config file.
const { getDefaultConfig } = require('@expo/metro-config');
const defaultConfig = getDefaultConfig(__dirname); defaultConfig.resolver.sourceExts.push('cjs');
module.exports = defaultConfig;
- Next, you can either run either of the following commands to run on a simulator.
yarn ios yarn android yarn web
Adding a Navigation Stack to your project
- Add @react-navigation/native
@react-navigation/native
- Add @react-navigation/native-stack
yarn add @react-navigation/native-stack