Giter Site home page Giter Site logo

expo-firebase-starter's Introduction

expo-firebase-starter ๐Ÿ”ฅ

Supports Expo iOS Supports Expo Android

Is a quicker way to start with Expo + Firebase (using JS SDK) projects. It includes:

  • based on Expo SDK 43
  • navigation using react-navigation 6.x.x
  • Firebase JS SDK v9
  • Firebase as backend for email auth
  • custom and reusable components
  • custom hook to toggle password field visibility on a TextInput
  • handles server errors using Formik
  • Login, Signup & Password Reset form built using Formik & yup
  • show/hide Password Field's visibility ๐Ÿ‘
  • uses a custom Provider using Context API & Firebase's onAuthStateChanged handler to checks user's auth state with
  • handles Forgot Password Reset using Firebase email method
  • uses Expo Vector Icons
  • uses KeyboardAwareScrollView package to handle keyboard appearance and automatically scrolls to focused TextInput
  • uses dotenv and expo-constants packages to manage environment variables (so that they are not exposed on public repositories)
  • all components are now functional components and use React Hooks

Installation

  1. Create a new project using the firebase starter template.
$ npx create-react-native-app --template https://github.com/expo-community/expo-firebase-starter
  1. Rename the file example.env to .env
  2. Update .env with your own configuration, e.g.:
# Rename this file to ".env" before use
# Replace XXXX's with your own Firebase config keys
API_KEY=XXXX
AUTH_DOMAIN=XXXX
PROJECT_ID=XXXX
STORAGE_BUCKET=XXXX
MESSAGING_SENDER_ID=XXXX
APP_ID=XXXX
  1. Start the project:
  • yarn ios -- open on iOS
  • yarn android -- open on Android

File Structure

Expo Firebase Starter
โ”œโ”€โ”€ assets โžก๏ธ All static assets, includes app logo
โ”œโ”€โ”€ components โžก๏ธ All re-suable UI components for form screens
โ”‚   โ””โ”€โ”€ Button.js โžก๏ธ Custom Button component using Pressable, comes with two variants and handles opacity
โ”‚   โ””โ”€โ”€ TextInput.js โžก๏ธ Custom TextInput component that supports left and right cons
โ”‚   โ””โ”€โ”€ Icon.js โžก๏ธ Icon component
โ”‚   โ””โ”€โ”€ FormErrorMessage.js โžก๏ธ Component to display server errors from Firebase
โ”‚   โ””โ”€โ”€ LoadingIndicator.js โžก๏ธ Loading indicator component
โ”‚   โ””โ”€โ”€ Logo.js โžก๏ธ Logo component
โ”‚   โ””โ”€โ”€ View.js โžก๏ธ Custom View component that supports safe area views
โ”œโ”€โ”€ hooks โžก๏ธ All custom hook components
โ”‚   โ””โ”€โ”€ useTogglePasswordVisibility.js โžก๏ธ A custom hook that toggles password visibility on a TextInput component on a confirm password field
โ”œโ”€โ”€ config โžก๏ธ All configuration files
โ”‚   โ””โ”€โ”€ firebase.js โžก๏ธ Configuration file to initialize firebase with firebaseConfig and auth
โ”‚   โ””โ”€โ”€ images.js โžก๏ธ Require image assets, reusable values across the app
โ”‚   โ””โ”€โ”€ theme.js โžก๏ธ Default set of colors, reusable values across the app
โ”œโ”€โ”€ providers โžก๏ธ All custom providers that use React Context API
โ”‚   โ””โ”€โ”€ AuthenticatedUserProvider.js โžก๏ธ An Auth User Context component that shares Firebase user object when logged-in
โ”œโ”€โ”€ navigation
โ”‚   โ””โ”€โ”€ AppStack.js โžก๏ธ Protected routes such as Home screen
โ”‚   โ””โ”€โ”€ AuthStack.js โžก๏ธ Routes such as Login screen, when the user is not authenticated
โ”‚   โ””โ”€โ”€ RootNavigator.js โžก๏ธ Switch between Auth screens and App screens based on Firebase user logged-in state
โ”œโ”€โ”€ screens
โ”‚   โ””โ”€โ”€ ForgotPassword.js โžก๏ธ Forgot Password screen component
โ”‚   โ””โ”€โ”€ HomeScreen.js โžก๏ธ Protected route/screen component
โ”‚   โ””โ”€โ”€ LoginScreen.js โžก๏ธ Login screen component
โ”‚   โ””โ”€โ”€ SignupScreen.js โžก๏ธ Signup screen component
โ”œโ”€โ”€ App.js โžก๏ธ Entry Point for Mobile apps, wrap all providers here
โ”œโ”€โ”€ app.config.js โžก๏ธ Expo config file
โ””โ”€โ”€ babel.config.js โžก๏ธ Babel config (should be using `babel-preset-expo`)

Screens

Main screens:

  • Login
  • Signup
  • Forgot password
  • Home (Bare Minimum) with a logout button

Login screen with validation

Successful Signup

Forgot Password

Validation on Signup screens

โš ๏ธ Please Note

Expo uses Firebase Web SDK and does not support all Firebase services such as phone auth. If you are looking forward to use those services, please use react-native-firebase in a Expo bare project, or an Expo custom dev client or a plain React Native project.

Here is more on what and why Expo cannot support complete Firebase integration


Built with ๐Ÿ’œ by @amanhimself

expo-firebase-starter's People

Contributors

amandeepmittal avatar bycedric avatar saajan avatar tiagoseverino avatar zyzmoz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.