A fullstack web application built with React (frontend) and Express + PostgreSQL (backend) implementing user authentication with JWT π.
- π Sign Up: Create new user, validate inputs, hash password, return JWT
- π Sign In: Validate credentials, return JWT
- π‘ Protected Route: /api/users/me returns logged-in user info
- πΎ Token Handling: Store JWT in localStorage, used for API requests
- πͺ Sign Out: Clears token and user info
cd backend npm install
Create .env file with:
DB_HOST=localhost DB_USER=your_db_username DB_PASSWORD=your_db_password DB_NAME=your_db_name DB_PORT=5432 JWT_SECRET=supersecretkey JWT_EXPIRES_IN=1d
Start backend server:
npm run dev
Frontend
cd frontend npm install npm start
π Frontend: http://localhost:3000 π Backend: http://localhost:5000
πββ Usage
-
Open the app in your browser
-
π Sign Up with a new email
-
π Sign In with existing credentials
-
π View Home page showing Name + Phone
-
πͺ Sign Out to remove token
β Testing
π’ Sign Up / Sign In with valid inputs
π΄ Sign Up / Sign In with invalid inputs β error messages
π‘ Access /api/users/me with valid/invalid JWT
πΎ Verify JWT stored in localStorage
πͺ Sign Out removes token and blocks access
πΈ Screenshots
-
Sign Up success β
-
Sign In success β
-
Home page showing Name + Phone π
π Technologies
Frontend: React, React Router DOM
Backend: Node.js, Express, PostgreSQL, bcryptjs, jsonwebtoken, cors, dotenv