A simple URL shortening service built with Next.js.
- Shorten long URLs
- Redirect short URLs to their original URLs
- View all shortened URLs
- Next.js
- TypeScript
- TailwindCSS
- MongoDB
- Mongoose
- Node.js
- MongoDB
-
Clone the repository:
git clone https://github.com/THEYASHGAUR/Next.js-URL-Shortner.git cd Next.js-URL-Shortner
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env.local
file in the root directory and add the following:MONGODB_URI=<your_mongodb_connection_string> NEXT_PUBLIC_BASE_URL=http://localhost:3000
-
Run the development server:
npm run dev
-
Open your browser: Navigate to http://localhost:3000
components/
: React componentspages/
: Next.js pagesservices/
: Business logic for URL shorteningrepositories/
: Data access logicmodals/
: Mongoose modelsconfig/
: Database configuration
POST /api/shorten
: Shorten a URLGET /:shortUrl
: Redirect to the original URL