A modern and complete authentication system with React that includes registration, login, session management and route protection with a beautiful dark glassmorphism design.
- β Protected Routes: Protection of sensitive pages with React Router
- β Auth Context: User state management with Context API
- β Form Validation: Form validation with Yup and Formik
- β Mock API: Simulated API with json-server
- β LocalStorage: Session persistence after page refresh
- β Responsive Design: Responsive design with Tailwind CSS
- β Dark Glassmorphism UI: Modern dark theme with glassmorphism effects
- β Loading States: Loading state display
- β Error Handling: Error management and appropriate message display
- β Toast Notifications: Success and error message display
- β Remember Me: User remember functionality
- React 19 - Main library
- React Router DOM - Routing management and protected routes
- Axios - API communication
- Formik + Yup - Form management and validation
- Tailwind CSS - UI design with glassmorphism
- Context API - State management
- json-server - Mock API
src/
βββ api/
β βββ auth.js # API functions for authentication
βββ components/
β βββ FormInput.jsx # Input component with validation
β βββ Loader.jsx # Loading component
β βββ Navbar.jsx # Navigation bar
β βββ Toast.jsx # Message display component
βββ context/
β βββ AuthContext.jsx # User state management
βββ pages/
β βββ Home.jsx # Home page
β βββ Login.jsx # Login page
β βββ Register.jsx # Registration page
β βββ Dashboard.jsx # User dashboard
βββ routes/
β βββ ProtectedRoute.jsx # Route protection
βββ App.jsx # Main component
βββ main.jsx # Application entry point
- Node.js (version 18 or higher)
- npm or yarn
- Clone the project
git clone <repository-url>
cd authlab-react- Install dependencies
npm install- Start Mock API
npm run api- Start React application
npm run dev- Access the application
- React App: http://localhost:5173
- Mock API: http://localhost:3001
- Welcome and project introduction
- Login and registration links
- Project features display
- Login form with email and password
- Validation with Yup
- "Remember me" functionality
- Error handling
- Registration form with complete fields
- Password confirmation
- Advanced validation
- Auto-login after registration
- Protected page
- User information display
- Quick actions
- Logout button
GET http://localhost:3001/usersPOST http://localhost:3001/users
Content-Type: application/json
{
"name": "User Name",
"email": "user@example.com",
"password": "password123"
}- Enter home page β Choose Login or Register
- Registration β Fill form β Confirm β Auto-login to Dashboard
- Login β Fill form β Confirm β Enter Dashboard
- Dashboard β View information β Logout
- Protection of sensitive routes
- Form validation
- Session management with LocalStorage
- API error handling
- Dark Theme: Modern dark color scheme
- Glassmorphism: Frosted glass effects with backdrop blur
- Gradients: Beautiful gradient backgrounds
- Transparency: Semi-transparent elements
- Modern UI: Clean and contemporary design
- Connect to real Backend (Laravel/Node.js)
- Password change functionality
- Forgot password
- Two-factor authentication
- Advanced user profile
- Role and permission system
npm run dev # Start development server
npm run build # Build production build
npm run preview # Preview production build
npm run api # Start Mock API
npm run lint # Check code with ESLintTo contribute to this project:
- Fork it
- Create a new branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
This project is published under the MIT license.
This project has been developed as a complete example of an authentication system with React and modern UI design.
Note: This project is designed for educational and practice purposes. For production use, be sure to add more security and validation features.
You can test the application with these demo users:
-
Test User
- Email:
test@example.com - Password:
123456
- Email:
-
Dev Amir
- Email:
devamir99@example.com - Password:
123456
- Email: