A modern, feature-rich URL shortener built with Next.js 16, Firebase Realtime Database, and beautiful analytics dashboard.
- 🔗 URL Shortening: Create short links with custom aliases
- 📊 Analytics Studio: Comprehensive analytics dashboard with:
- Overview statistics (Total Clicks, Unique Visitors, Avg CTR, Top Country)
- Click timeline charts
- Geographic analytics (Country distribution)
- Device & Browser statistics
- Traffic source analysis
- Link-specific analytics (select any link to see its individual stats)
- Real-time activity feed
- 🗺️ Live Traffic Map: Interactive world map showing click distribution by country
- 📱 Responsive Design: Beautiful, modern UI that works on all devices
- 🎨 Dark Theme: Optimized for dark mode with balanced white/black theme
- Framework: Next.js 16 (App Router)
- Database: Firebase Realtime Database
- Styling: Tailwind CSS
- Charts: Recharts, d3-geo
- Animations: Framer Motion
- Icons: Phosphor React
- Node.js 20.x or higher
- npm or yarn
- Firebase project with Realtime Database enabled
- Clone the repository:
git clone <your-repo-url>
cd link-palette-nextjs- Install dependencies:
npm install- Set up environment variables:
Create a
.env.localfile in the root directory:
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
NEXT_PUBLIC_FIREBASE_DATABASE_URL=your_database_url
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=your_measurement_id-
Configure Firebase Realtime Database Rules: See
FIREBASE_RULES.mdfor instructions. -
Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
See VERCEL_DEPLOYMENT.md for detailed deployment instructions.
- Push your code to GitHub/GitLab/Bitbucket
- Go to vercel.com/new
- Import your repository
- Add environment variables (see
.env.example) - Click Deploy
├── app/
│ ├── api/ # API routes
│ │ ├── analytics/ # Analytics endpoints
│ │ ├── links/ # Link management
│ │ ├── redirect/ # URL redirection
│ │ └── shorten/ # Link shortening
│ ├── [shortCode]/ # Dynamic redirect page
│ └── page.tsx # Home page
├── components/
│ ├── analytics-studio.tsx # Analytics dashboard
│ ├── layout.tsx # Main layout with downpanel
│ └── visual-map.tsx # World map component
├── lib/
│ └── firebase.ts # Firebase configuration
└── public/ # Static assets
POST /api/shorten- Create a short linkGET /api/links- Get all links
GET /api/analytics/overview- Overall statisticsGET /api/analytics/timeline?range=7d- Timeline dataGET /api/analytics/devices- Device statisticsGET /api/analytics/referrers- Traffic sourcesGET /api/analytics/recent-activity- Recent clicksGET /api/analytics/link/[linkId]- Individual link statsGET /api/stats/countries- Country statistics
GET /api/redirect/[shortCode]- Redirect to original URL
All Firebase configuration should be set as environment variables with NEXT_PUBLIC_ prefix to be available in the browser.
- Create a Firebase project at Firebase Console
- Enable Realtime Database
- Set up security rules (see
FIREBASE_RULES.md) - Get your Firebase config values
- Add them to
.env.localor Vercel environment variables
MIT
For issues and questions, please open an issue on GitHub.