Best Tech Stack for a URL Shortener as a Solo Developer
The best tech stack for building a URL shortener as a solo developer - frameworks, databases, hosting, and tools.
Best Tech Stack for a URL Shortener as a Solo Developer
URL shorteners look simple on the surface. Take a long URL, generate a short one, redirect when someone clicks it. But the products that make money in this space, like Dub.co, Short.io, and Bitly, layer on link analytics, custom domains, team workspaces, QR codes, and API access. That's where the value is, and that's what makes the stack choice interesting.
The redirect endpoint is the critical path. It needs to be fast (every millisecond of redirect latency matters), globally distributed, and able to handle spikes. Here's the stack that gets this right.
Recommended Stack at a Glance
| Layer | Pick |
|---|---|
| Redirect Layer | Cloudflare Workers |
| Dashboard | Next.js (React) |
| Database | PostgreSQL + Redis |
| Analytics | Tinybird (ClickHouse) |
| ORM | Drizzle ORM |
| Hosting | Vercel (dashboard) |
| Payments | Stripe |
The Core: Cloudflare Workers for Redirects
The redirect endpoint is your highest-traffic path. Every time someone clicks a short link, your system needs to look up the destination URL and return a 301/302 redirect in milliseconds. This needs to be fast globally since links are shared everywhere.
Cloudflare Workers are the best choice for a solo developer:
- Edge deployment - Your redirect runs in 300+ data centers worldwide. Sub-10ms response times everywhere.
- Zero cold starts - Unlike Lambda or other serverless functions, Workers start instantly.
- Built-in KV storage - Store short code to URL mappings in Cloudflare KV for edge-speed lookups.
- Massive free tier - 100,000 requests/day free. That's 3 million redirects/month at zero cost.
The Worker logic is straightforward: receive request, extract the short code from the URL path, look it up in KV, log the click event, and redirect. Fifteen lines of code for the core functionality.
Use Cloudflare KV as your primary lookup store. KV is eventually consistent (updates propagate globally in ~60 seconds), which is perfectly fine for URL shortening. When a user creates a new short link, write it to both PostgreSQL (source of truth) and KV (fast lookup cache).
Dashboard: Next.js
The dashboard is where users create links, view click analytics, manage custom domains, and configure their account. Next.js handles this standard SaaS dashboard pattern well.
Key dashboard features:
- Link creation - URL input, custom alias, UTM parameter builder, expiration date
- Analytics - Click counts, geographic breakdown, referrer data, device/browser stats
- QR code generation - Generate and download QR codes for any short link
- Custom domains - Let users bring their own domains for branded short links
- API keys - Manage API access for programmatic link creation
For QR code generation, use the qrcode npm package. It generates QR codes as SVG, PNG, or data URIs entirely on the server. No external API needed.
Database: PostgreSQL + Redis
PostgreSQL is your source of truth for all link data, user accounts, and configuration:
links- Short code, destination URL, creator, custom domain, expires_at, click countusers- Account details, plan, API keysdomains- Custom domains with DNS verification statusworkspaces- Team workspaces for collaboration
Redis serves two purposes:
- Rate limiting - Prevent API abuse and creation spam. Use sliding window rate limiting per API key.
- Real-time counters - Increment click counts in Redis and batch-write to PostgreSQL periodically. This prevents PostgreSQL write bottlenecks during traffic spikes.
For click analytics data (timestamps, geo, referrer, device), send events to Tinybird (ClickHouse-based) rather than PostgreSQL. Analytics queries over millions of clicks need a columnar database. See the analytics section below.
Host PostgreSQL on Neon (serverless, free tier) and Redis on Upstash (serverless, free tier).
Analytics: Tinybird
When someone clicks a short link, your Worker logs the event with metadata: timestamp, country (from Cloudflare headers), referrer, user agent, device type. These events accumulate fast. A moderately popular link can generate millions of clicks.
Tinybird ingests these click events and lets you query them with SQL. Create API endpoints for common queries: clicks over time, top countries, top referrers, device breakdown. The free tier handles 10GB of data and 1,000 API requests/day.
The flow: Worker logs click to Tinybird's ingestion API (async, fire-and-forget), dashboard queries Tinybird's published endpoints for analytics views.
This separation keeps your PostgreSQL lean (just link metadata and user data) while giving you powerful analytics on click data.
Custom Domains: Cloudflare
Custom domains are a premium feature that users will pay for. Implementation with Cloudflare:
- User adds their custom domain in your dashboard
- They add a CNAME record pointing to your Cloudflare Worker route
- Your Worker checks the incoming hostname, looks up which user owns that domain, and processes the redirect
Cloudflare for SaaS (Custom Hostnames) handles the SSL certificate provisioning for custom domains automatically. This is a paid Cloudflare feature ($2/month base + $0.10/custom hostname), but it's far easier than managing certificates yourself.
Nice-to-Haves
- Stripe for subscription billing (free tier + paid plans)
- Cloudflare Turnstile for bot protection on the link creation form
- Plausible or Umami for your own marketing site analytics
- Resend for transactional emails (link reports, team invitations)
- OG image preview - Fetch and display destination URL's Open Graph image during link creation
Monthly Cost Breakdown
| Service | Cost |
|---|---|
| Cloudflare Workers (free tier) | $0 |
| Cloudflare KV | $0 (free tier) |
| Vercel (Pro) | $20/month |
| Neon Postgres (free tier) | $0 |
| Upstash Redis (free tier) | $0 |
| Tinybird (free tier) | $0 |
| Short domain (.co, .link, etc.) | $5-15/year |
| Total | ~$20-21/month |
If you add custom domain support via Cloudflare for SaaS, add $2/month base + $0.10 per custom hostname.
Conclusion
The best stack for a solo developer building a URL shortener: Cloudflare Workers for globally distributed redirects with KV for fast lookups, Next.js for the dashboard, PostgreSQL for application data, Tinybird for click analytics, and Redis for rate limiting.
The architectural insight is separating the redirect path (Cloudflare Workers, must be fast and global) from the dashboard (Vercel, standard web app) and analytics (Tinybird, optimized for aggregation queries). Each component is simple on its own, and together they handle the distinct performance requirements of a URL shortener. Don't try to serve redirects from the same Node.js process that renders your dashboard. The two have fundamentally different performance requirements.
Related Articles
AI Wrapper Stack Guide for Solo Developers
Complete guide to the AI wrapper stack - when to use it, setup, pros/cons, and alternatives.
Best Tech Stack for Building an AI Wrapper as a Solo Developer
The ideal tech stack for solo developers building an AI wrapper in 2026.
Best Tech Stack for an Analytics Dashboard as a Solo Developer
The best tech stack for building an analytics dashboard as a solo developer - frameworks, databases, hosting, and tools.