A simple URL shortener application with a Next.js frontend and Express.js backend.
- Shorten long URLs into manageable links
- View and track click statistics
- Copy shortened URLs to clipboard with one click
- Responsive design for mobile and desktop
- Recent URL history
This project consists of two main parts:
- Frontend: Built with Next.js and Tailwind CSS
- Backend: Built with Express.js, MongoDB, and Node.js
- Node.js (v14 or later)
- MongoDB (local or remote instance)
-
Navigate to the backend directory
cd backend
-
Install dependencies
npm install
-
Create a
.env
file with the following variablesPORT=5000 MONGO_URI=mongodb://localhost:27017/url-shortener BASE_URL=http://localhost:5000
-
Start the development server
npm run dev
-
Navigate to the frontend directory
cd frontend
-
Install dependencies
npm install
-
Start the development server
npm run dev
- Open your browser and go to
http://localhost:3000
- Enter a long URL in the input field
- Click "Shorten URL"
- Copy the shortened URL and share it
- POST /api/shorten: Create a short URL
- GET /api/:code: Redirect to the original URL
- GET /api/urls/all: Get all URLs
- Next.js
- React
- TypeScript
- Tailwind CSS
- Express.js
- MongoDB with Mongoose
- Node.js
This project is licensed under the MIT License.