Email/password authentication demo built with React Router, Firebase Auth, and Vite. Users can sign up, log in, reset a password, and access a protected dashboard with session-aware routing.
- Email/password signup and login with Firebase Auth
- Password reset via email
- Protected routes that redirect unauthenticated users
- Auth state persistence and loading guard
- Simple dashboard with sign out
- Node.js 18+ and npm
- A Firebase project with Email/Password authentication enabled
- Install dependencies:
npm install
- Configure Firebase:
- Create a Web App in Firebase Console and enable Email/Password auth.
- Replace the config inside
src/firebase/firebase.jswith your project credentials:
const firebaseConfig = { apiKey: "...", authDomain: "...", projectId: "...", storageBucket: "...", messagingSenderId: "...", appId: "...", };
- Start the dev server:
npm run dev
Vite will show the local URL (default http://localhost:5173).
npm run dev– start Vite dev servernpm run build– production buildnpm run preview– preview the production buildnpm run lint– run eslint
src/App.jsx– routes and protected route wrappersrc/context/AuthContext.jsx– auth state and sign out helpersrc/components/login/– login + reset password flowsrc/components/sign-up/– registration flowsrc/components/dashboard/– protected dashboardsrc/firebase/firebase.js– Firebase initialization
- If you see analytics errors in development, remove
getAnalyticsor guard it for browser-only usage. - Update routing paths as needed if you deploy behind a subpath.