React Face Auth is a facial recognition-based authentication web application built with React and face-api.js. It provides a secure and efficient way to authenticate users by analyzing their facial features. The application features a clean, custom CSS-styled interface, replacing utility-first frameworks like Tailwind CSS for a more tailored styling approach.
- Facial Recognition Authentication: Uses face-api.js to verify users based on facial features.
- User Selection: Allows selection of predefined dummy users or uploading custom user images.
- Responsive Design: Custom CSS ensures a consistent experience across devices.
- Protected Routes: Restricts access to authenticated users only.
- Error Handling: Displays clear error messages for failed authentications or missing profile images.
- React: Frontend JavaScript library for building user interfaces.
- face-api.js: Machine learning library for facial recognition in the browser.
- Headless UI: Unstyled, accessible UI components for radio groups and other interactions.
- React Router: Declarative routing for single-page applications.
- Custom CSS: Hand-crafted styles in
styles.cssfor complete control over the UI. - Vite: Build tool for fast development and production builds (assumed; adjust if using Create React App or another tool).
-
Clone the Repository:
git clone https://github.com/BilalGumus/react-face-auth.git cd react-face-auth -
Install Dependencies: Ensure you have Node.js installed. Then, run:
npm install
-
Set Up Models: Place the face-api.js model files in the
public/modelsdirectory. You can download them from the face-api.js repository or use a CDN (update theuriinLogin.jsxif using a CDN). -
Add Temporary Accounts: Place dummy user images in the
public/temp-accountsdirectory, structured aspublic/temp-accounts/[user-id]/[image-name].jpg(e.g.,public/temp-accounts/374ed1e4-481b-4074-a26e-6137657c6e35/1.jpg). -
Run the Application: Start the development server:
npm run dev
Open
http://localhost:5173(or the port specified by your build tool) in your browser.
- Home Page: View the welcome message and click "Log In" to proceed.
- User Selection:
- Choose a dummy user from the list or upload a custom image (PNG, JPG, or JPEG).
- Click "Continue" to proceed to authentication.
- Face Authentication:
- Allow webcam access when prompted.
- The app will scan your face and compare it to the selected user's image.
- On successful recognition, you'll be redirected to the protected page after a 5-second countdown.
- If recognition fails or no profile image is found, an error message is displayed.
- Protected Page: View user details and log out to return to the home page.
- Footer: Links to the creator's GitHub profile.
react-face-auth/
├── public/
│ ├── models/ # face-api.js model files
│ ├── temp-accounts/ # Dummy user images
│ └── ... # Other public assets
├── src/
│ ├── assets/
│ │ ├── auth-idle.svg # Loading icon
│ │ └── auth-face.svg # Face scan icon
│ ├── components/
│ │ ├── Footer.jsx # Footer with creator credit
│ │ └── User.jsx # User selection radio option
│ ├── Home.jsx # Home page with app description
│ ├── Layout.jsx # Layout with routing logic
│ ├── Login.jsx # Face authentication page
│ ├── Protected.jsx # Protected page for authenticated users
│ ├── UserSelect.jsx # User selection page
│ └── ... # Other source files (e.g., App.jsx, main.jsx)
├── package.json # Project dependencies and scripts
└── README.md # Project documentation
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m "Add your feature"). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
Please ensure your code follows the project's coding style and includes tests where applicable.
This project is licensed under the MIT License. See the LICENSE file for details.
Created by Sarthak Singh with 💙.