A simple, fast, and lightweight URL Shortener application built with Node.js, Express, and MongoDB.
- Generate short URLs for long links.
- Stores total visit counts and timestamp analytics for generated short URLs.
- EJS server-side rendering for a simple UI.
- Node.js & Express.js: Backend framework
- MongoDB & Mongoose: Database and ODM
- EJS: View engine
- shortid: To generate unique random short IDs
- dotenv: Environment variable management
- Node.js installed
- MongoDB connection string (local or MongoDB Atlas)
-
Clone the repository and install dependencies:
npm install
-
Environment Variables: Create a
.envfile in the root directory by copying the.env.examplefile:cp .env.example .env
Open
.envand configure yourMONGODB_URI:MONGODB_URI="mongodb+srv://<username>:<password>@cluster.mongodb.net/..." -
Start the application: For development (uses nodemon):
npm run dev
For production:
npm start
-
Usage: Open your browser and navigate to
http://localhost:8001. You can enter a long URL to get a shortened version.