A simple, fast URL shortener built with Node.js, Express, and MongoDB. Features include click tracking and a clean, responsive interface.
- 🔗 URL Shortening
- 📊 Click Analytics
- 🚀 Fast Redirects
- 📱 Mobile-Friendly UI
- 🔄 Real-time Stats
Visit [your-vercel-url] to try it out!
- Frontend: HTML, Tailwind CSS
- Backend: Node.js, Express
- Database: MongoDB
- Deployment: Vercel
- Other: nanoid (for URL generation)
- Clone the repository:
git clone https://github.com/yourusername/url-shortener.git
cd url-shortener- Install dependencies:
npm install- Set up environment variables:
Create a
.envfile in the root directory:
MONGODB_URI=your_mongodb_connection_string- Run locally:
npm startVisit http://localhost:3000 to see the app.
This project is configured for easy deployment on Vercel:
- Install Vercel CLI:
npm i -g vercel- Deploy:
vercel-
POST /api/shorten: Create a new short URL- Body:
{ "url": "https://example.com" } - Response:
{ "shortUrl": "abc123", ... }
- Body:
-
GET /api/stats/:shortUrl: Get URL statistics- Response:
{ "clicks": 0, "createdAt": "2024-..." }
- Response:
- Ensure MongoDB is running locally or use MongoDB Atlas
- Update environment variables as needed
- Install dependencies:
npm install - Start development server:
npm run dev
- Fork the repository
- Create your feature 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 - Open a Pull Request
This project is MIT licensed - see LICENSE.md for details
- Built with Express
- Styled with Tailwind CSS
- Deployed on Vercel
- Database hosted on MongoDB Atlas