An open API service indexing awesome lists of open source software.

https://github.com/yuvrajnode/jwt-auth-app

A simple full-stack authentication app using Node.js, Express, JWT, and a clean HTML/JavaScript frontend
https://github.com/yuvrajnode/jwt-auth-app

authentication express jwt nodejs rest-api

Last synced: about 2 months ago
JSON representation

A simple full-stack authentication app using Node.js, Express, JWT, and a clean HTML/JavaScript frontend

Awesome Lists containing this project

README

          

๐Ÿ” JWT Auth Login App

This is a simple full-stack authentication app built using **Node.js**, **Express**, and **JWT** on the backend, with a clean **HTML/CSS + JavaScript frontend** using **Axios** for API calls.

It demonstrates how to create, sign in, and validate users using **JSON Web Tokens**.

๐Ÿ“ Project Structure

```
W6-auth-app/
โ”‚
โ”œโ”€โ”€ public/
โ”‚ โ””โ”€โ”€ index.html # Frontend UI (Signup, Signin, Logout)
โ”‚
โ”œโ”€โ”€ index.js # Express backend
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md
```

โš™๏ธ Features

โœ… Signup new users
โœ… Signin existing users
โœ… Get user info using JWT
โœ… JWT is stored in `localStorage`
โœ… Middleware-protected route (`/me`)
โœ… Clean frontend layout
โœ… Logging via middleware

๐Ÿงช Technologies Used

Frontend:
- HTML5, CSS3
- JavaScript
- Axios (via CDN)

Backend:
- Node.js
- Express.js
- JSON Web Token (`jsonwebtoken`)

๐Ÿš€ Getting Started

1. Clone the repository

```bash
git clone https://github.com/yuvrajnode/jwt-auth-login-api.git
cd jwt-auth-login-api
```

2. Install dependencies

```bash
npm install
```

3. Run the server

```bash
node index.js
```

Visit:
๐Ÿ‘‰ `http://localhost:3000`

๐ŸŒ Frontend Preview

When you open `http://localhost:3000`:

- You can **Signup** โ†’ token is generated and stored in `localStorage`
- You can **Signin** โ†’ token received on login
- **User info** loads automatically if logged in
- **Logout** clears the token

๐Ÿ“ฆ API Endpoints

| Method | Endpoint | Description |
|--------|---------------|------------------------------|
| POST | `/signup` | Register a new user |
| POST | `/signin` | Login and receive a token |
| GET | `/me` | Get logged-in user info (protected) |

๐Ÿ›ก๏ธ Authentication Flow

1. User signs up or logs in โ†’ receives a **JWT**
2. Token is stored in **`localStorage`**
3. Frontend sends this token in **`Authorization` header**
4. Backend middleware (`auth`) verifies token and extracts user