A modern full-stack URL shortener web application built using the MERN stack.
Users can shorten long URLs instantly and get clean, shareable short links with redirect functionality and click tracking.
- Shorten long URLs
- Unique short code generation
- Redirect to original URL
- Click tracking
- Responsive modern UI
- Copy-to-clipboard functionality
- Toast notifications
- REST API architecture
- MongoDB database integration
- Clean backend structure
- React
- Vite
- Tailwind CSS
- Axios
- React Hot Toast
- Node.js
- Express.js
- MongoDB
- Mongoose
- NanoID
- Validator
url-shortener/
│
├── backend/
│ ├── src/
│ │ ├── config/
│ │ ├── controllers/
│ │ ├── middleware/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── utils/
│ │ └── server.js
│ │
│ ├── .env.example
│ ├── package.json
│ └── .gitignore
│
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ ├── services/
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── index.css
│ │
│ ├── .env.example
│ ├── package.json
│ └── .gitignore
│
└── README.mdgit clone <your-repo-url>
cd url-shortenercd backendnpm installCreate a .env file inside backend:
PORT=5000
MONGO_URI=your_mongodb_connection_string
BASE_URL=http://localhost:5000npm run devBackend runs on:
http://localhost:5000cd frontendnpm installCreate a .env file inside frontend:
VITE_API_URL=http://localhost:5000/apinpm run devFrontend runs on:
http://localhost:5173docker compose up --builddocker compose downFrontend: http://localhost:5173
Backend: http://localhost:5000
---
# API Endpoints
## Create Short URL
### Request
```http
POST /api/url/shorten
{
"originalUrl": "https://google.com"
}{
"success": true,
"shortUrl": "http://localhost:5000/abc123"
}GET /:shortCodeGET /abc123Redirects user to the original URL.
| Variable | Description |
|---|---|
| PORT | Backend server port |
| MONGO_URI | MongoDB connection string |
| BASE_URL | Backend base URL |
| Variable | Description |
|---|---|
| VITE_API_URL | Backend API URL |
- Vercel
- Render
- MongoDB Atlas
Meet Vora
If you like this project, give it a ⭐ on GitHub!