url-redirect Tailwind Templates

Url Redirect

A production-grade URL redirection system built with Next.js 15, TypeScript, and Tailwind CSS.

URL Redirector

A production-grade URL redirection system built with Next.js 15, TypeScript, and Tailwind CSS.

Features

  • šŸš€ 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

Getting Started

Prerequisites

  • Node.js 20+
  • npm or yarn

Installation

  1. Clone the repository:
git clone https://github.com/0x3f-lancers/url-redirector.git
cd url-redirector
  1. Install dependencies:
npm install
  1. Create the initial redirects data file:
mkdir -p src/data
echo '{"redirects":[]}' > src/data/redirects.json
  1. Start the development server:
npm run dev

Visit http://localhost:3000 to see the dashboard.

Project Structure

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

Usage

Dashboard

Visit the dashboard at http://localhost:3000 to:

  • View all redirects
  • Search redirects
  • See visit statistics

API Endpoints

Create a new redirect

curl -X POST http://localhost:3000/api/redirects \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "example",
    "url": "https://example.com",
    "title": "Example Website"
  }'

Get all redirects

curl http://localhost:3000/api/redirects

Update a redirect

curl -X PATCH http://localhost:3000/api/redirects/example \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://new-example.com",
    "title": "Updated Example"
  }'

Delete a redirect

curl -X DELETE http://localhost:3000/api/redirects/example

Using Redirects

Once created, redirects are accessible at:

http://localhost:3000/{slug}

For example:

  • http://localhost:3000/github redirects to GitHub
  • http://localhost:3000/google redirects to Google

Security

The application includes several security features:

  • HTTP security headers
  • Input validation
  • XSS protection
  • CSRF protection
  • Content Security Policy

Development

Environment Variables

No environment variables are required for local development.

Type Checking

npm run type-check

Linting

npm run lint

Production Deployment

  1. Build the application:
npm run build
  1. Start the production server:
npm start

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Created by Ad-h0c & Lancers Technology

Top categories

Loading Svelte Themes