A production-grade URL redirection system built with Next.js 15, TypeScript, and Tailwind CSS.
- 🚀 Built with Next.js 15 App Router
- 💪 TypeScript for type safety
- 🎨 Tailwind CSS for styling
- ✅ Zod for data validation
- 📊 Visit tracking
- 🔍 Real-time search functionality
- 🛡️ Security headers
- 📱 Responsive dashboard UI
- 🌐 RESTful API endpoints
- Node.js 20+
- npm or yarn
- Clone the repository:
git clone https://github.com/0x3f-lancers/url-redirector.git
cd url-redirector- Install dependencies:
npm install- Create the initial redirects data file:
mkdir -p src/data
echo '{"redirects":[]}' > src/data/redirects.json- Start the development server:
npm run devVisit http://localhost:3000 to see the dashboard.
URL-Redirector
├── README.md
├── app
│ ├── [slug]
│ │ └── route.ts
│ ├── api
│ │ └── redirects
│ │ ├── [slug]
│ │ │ └── route.ts
│ │ └── route.ts
│ ├── components
│ │ ├── redirects-table.tsx
│ │ └── search-input.tsx
│ ├── data
│ │ └── redirects.json
│ ├── error.tsx
│ ├── favicon.ico
│ ├── globals.css
│ ├── layout.tsx
│ ├── lib
│ │ ├── redirect.ts
│ │ └── validations
│ │ └── redirect.ts
│ ├── middleware.ts
│ ├── not-found.tsx
│ ├── page.tsx
│ └── types
│ └── redirects.ts
├── next-env.d.ts
├── next.config.ts
├── package-lock.json
├── package.json
├── postcss.config.mjs
├── tailwind.config.ts
└── tsconfig.json
Visit the dashboard at http://localhost:3000 to:
- View all redirects
- Search redirects
- See visit statistics
curl -X POST http://localhost:3000/api/redirects \
-H "Content-Type: application/json" \
-d '{
"slug": "example",
"url": "https://example.com",
"title": "Example Website"
}'curl http://localhost:3000/api/redirectscurl -X PATCH http://localhost:3000/api/redirects/example \
-H "Content-Type: application/json" \
-d '{
"url": "https://new-example.com",
"title": "Updated Example"
}'curl -X DELETE http://localhost:3000/api/redirects/exampleOnce created, redirects are accessible at:
http://localhost:3000/{slug}
For example:
http://localhost:3000/githubredirects to GitHubhttp://localhost:3000/googleredirects to Google
The application includes several security features:
- HTTP security headers
- Input validation
- XSS protection
- CSRF protection
- Content Security Policy
No environment variables are required for local development.
npm run type-checknpm run lint- Build the application:
npm run build- Start the production server:
npm start- 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 licensed under the MIT License - see the LICENSE file for details.
Created by Ad-h0c & Lancers Technology