A secure URL shortener service built with Next.js, Cloudflare Workers, and GitHub OAuth authentication. Create, manage, and track shortened URLs with analytics.
- 🔐 Secure GitHub authentication
- 🔗 Custom URL shortening with optional custom codes
- ⏰ URL expiration support
- 📊 Click analytics tracking
- 🌍 Geographic data collection
- 🎯 Dashboard for URL management
- Node.js 18 or higher
- A GitHub account
- A Cloudflare account
- wrangler CLI tool (
npm install -g wrangler
)
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set the homepage URL to your domain
- Set the callback URL to
{your-domain}/auth
- Save the Client ID and Client Secret
Create .env.local
in the root directory:
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:8787
GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
THE_GITHUB_USERNAME=your_github_username
Create worker/.dev.vars
for the Cloudflare Worker:
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
THE_GITHUB_USERNAME=your_github_username
# Install frontend dependencies
npm install
# Install worker dependencies
cd worker
npm install
- Start the Next.js development server:
npm run dev
- Start the Cloudflare Worker:
cd worker
npm run dev
The application will be available at:
- Frontend: http://localhost:3000
- API: http://localhost:8787
Deploy to Vercel:
vercel
- Create KV namespace and Analytics Engine dataset:
wrangler kv:namespace create URL_SHORTENER
wrangler analytics:dataset create URL_CLICK_TRACKING
-
Update
wrangler.toml
with your KV and Analytics bindings -
Deploy the worker:
cd worker
wrangler deploy
- Visit your deployed application
- Login with GitHub
- Create shortened URLs from the dashboard
- View analytics for your URLs
MIT
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.