Skip to content

pratikshajadhav08/react-firebase-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ FirebaseAuth

A production-ready React authentication system built with Firebase β€” featuring email/password sign-in, Google OAuth, password reset, and a post-login dashboard.


✨ Features

  • Email & Password Authentication

    • Sign up & sign in
    • Validation & error handling
    • Firebase auth integration
  • Google OAuth

    • One-click Google popup login
  • Password Reset

    • Sends password reset email
  • Password Strength Meter

    • Real-time password feedback
  • Auth Persistence

    • User session survives refresh using onAuthStateChanged
  • Dashboard

    • Shows:
      • UID
      • Email
      • Provider
      • Verification status
  • Firestore Ready

    • db already exported from Firebase config

πŸ›  Tech Stack

Layer Technology
Frontend React 18
Authentication Firebase Auth
Database Cloud Firestore
Hosting Firebase Hosting
Bundler Vite

πŸ“ Project Structure

firebase-auth/
β”œβ”€β”€ FirebaseAuth.jsx
β”œβ”€β”€ firebase/
β”‚   └── config.js
β”œβ”€β”€ hooks/
β”‚   └── useAuth.js
β”œβ”€β”€ utils/
β”‚   └── helpers.js
β”œβ”€β”€ styles/
β”‚   └── authStyles.js
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”œβ”€β”€ Toast.jsx
β”‚   β”œβ”€β”€ StrengthBar.jsx
β”‚   β”œβ”€β”€ Logo.jsx
β”‚   β”œβ”€β”€ GoogleIcon.jsx
β”‚   └── Divider.jsx
└── views/
    β”œβ”€β”€ LoginView.jsx
    β”œβ”€β”€ SignupView.jsx
    └── ResetView.jsx

πŸš€ Getting Started

1️⃣ Clone Repository

git clone : https://github.com/pratikshajadhav08/react-firebase-authentication
cd firebase-auth

2️⃣ Install Dependencies

npm install

3️⃣ Configure Firebase

Create a Firebase project from:

πŸ‘‰ https://console.firebase.google.com

Go to:

Project Settings β†’ Your Apps β†’ SDK Setup

Replace config inside:

firebase/config.js

With:

const firebaseConfig = {
  apiKey: "YOUR_API_KEY",
  authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
  projectId: "YOUR_PROJECT_ID",
  storageBucket: "YOUR_PROJECT_ID.appspot.com",
  messagingSenderId: "YOUR_SENDER_ID",
  appId: "YOUR_APP_ID",
};

4️⃣ Enable Authentication Providers

Inside Firebase Console:

Authentication β†’ Sign-in Method

Enable:

  • βœ… Email/Password
  • βœ… Google

5️⃣ Start Development Server

npm run dev

App runs at:

http://localhost:5173

🌍 Deployment

Build Project

npm run build

Deploy to Firebase Hosting

Install Firebase CLI

npm install -g firebase-tools

Login

firebase login

Initialize Hosting

firebase init hosting

Deploy

firebase deploy --only hosting

Firebase Hosting Setup

Prompt Answer
Which project? Your Firebase Project ID
Public directory? dist
Configure as SPA? Yes
Overwrite index.html? No

πŸ”₯ Firestore Example

import { db } from "./firebase/config";
import { collection, addDoc } from "firebase/firestore";

await addDoc(collection(db, "users"), {
  uid: user.uid,
  email: user.email,
  createdAt: new Date(),
});

πŸ” Environment Variables

Create a .env file:

VITE_API_KEY=your_api_key
VITE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_PROJECT_ID=your_project_id
VITE_STORAGE_BUCKET=your_project.appspot.com
VITE_MESSAGING_SENDER_ID=your_sender_id
VITE_APP_ID=your_app_id

Update firebase/config.js:

const firebaseConfig = {
  apiKey: import.meta.env.VITE_API_KEY,
  authDomain: import.meta.env.VITE_AUTH_DOMAIN,
  projectId: import.meta.env.VITE_PROJECT_ID,
  storageBucket: import.meta.env.VITE_STORAGE_BUCKET,
  messagingSenderId: import.meta.env.VITE_MESSAGING_SENDER_ID,
  appId: import.meta.env.VITE_APP_ID,
};

Add .env to .gitignore

echo ".env" >> .gitignore

Live at: https://react-firebase-authentication-two.vercel.app/

πŸ“¦ Future Improvements

  • Protected Routes
  • Role-Based Auth
  • Dark Mode
  • Email Verification
  • MFA Authentication
  • GitHub OAuth
  • User Profiles
  • Admin Dashboard

πŸ“š Resources


πŸ“„ License

MIT License

Releases

No releases published

Packages

 
 
 

Contributors