/ tech-stacks / Best Tech Stack for a URL Shortener as a Solo Developer
tech-stacks 11 min read

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.

Hero image for Best Tech Stack for a URL Shortener as a Solo Developer

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.

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.
  • Generous free tier - The Workers free plan includes 100,000 requests/day, resetting at 00:00 UTC. That covers roughly 3 million redirects/month at zero cost (per the Workers pricing docs, checked on 2026-05-30).

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).

KV's free tier maps cleanly to a URL shortener's read-heavy shape. Per the KV pricing docs (checked on 2026-05-30), the free plan gives you 100,000 key reads/day plus 1,000 writes, 1,000 deletes, and 1,000 list requests/day, with 1 GB of stored data. Redirects are reads, and link creation is the rare write, so the asymmetry works in your favor. Beyond the free allowances, reads cost $0.50 per million and writes cost $5.00 per million, so a runaway redirect load stays cheap while a write-heavy abuse pattern is the thing to watch.

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. The framework is at version 16.2.6 on npm and pulls roughly 40 million weekly downloads, so the ecosystem, hosting story, and Stack Overflow answers are about as deep as web frameworks get (npm next, checked on 2026-05-30).

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 (node-qrcode, version 1.5.4, around 8,100 GitHub stars and 13.5 million weekly npm downloads as of 2026-05-30). 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 count
  • users - Account details, plan, API keys
  • domains - Custom domains with DNS verification status
  • workspaces - Team workspaces for collaboration

Redis serves two purposes:

  1. Rate limiting - Prevent API abuse and creation spam. Use sliding window rate limiting per API key.
  2. Real-time counters - Increment click counts in Redis and batch-write to PostgreSQL periodically. This prevents PostgreSQL write bottlenecks during traffic spikes.

For talking to PostgreSQL, Drizzle ORM is the lightweight, TypeScript-first pick (version 0.45.2, around 34,600 GitHub stars and 9.7 million weekly npm downloads as of 2026-05-30). It runs on edge runtimes, which matters because the same schema and query layer can be shared between your Next.js dashboard and any edge code that touches Postgres.

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) and Redis on Upstash (serverless), both with free tiers that fit an early-stage shortener. Neon's free plan gives 0.5 GB of storage per project (up to 5 GB aggregate across projects) plus 100 compute-hours per month, and Upstash's free Redis tier covers 500,000 commands per month with a 256 MB data cap (Neon and Upstash pricing pages, checked on 2026-05-30).

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, including clicks over time, top countries, top referrers, and device breakdown. The free plan includes 10 GB of storage and a cap of 1,000 queries per day (10 QPS) across the whole organization, with no credit card required. Note that Tinybird's billing model is now based on vCPU-hours rather than processed data, so the old "you pay per GB scanned" mental model no longer applies (Tinybird pricing page and limits docs, checked on 2026-05-30).

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:

  1. User adds their custom domain in your dashboard
  2. They add a CNAME record pointing to your Cloudflare Worker route
  3. 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. Per the Cloudflare for SaaS plans page (checked on 2026-05-30), every plan tier (including Free) includes 100 custom hostnames at no extra cost, then charges $0.10 per additional hostname per month, up to a 50,000 hostname ceiling before you need Enterprise. There is no separate base fee on top of that. It is far easier than managing certificates yourself.

Nice-to-Haves

  • Stripe for subscription billing (free tier + paid plans). Stripe has no monthly fee. You pay 2.9% + $0.30 per successful online card charge in the US, so it costs nothing until you actually take money (Stripe pricing page, checked on 2026-05-30).
  • Cloudflare Turnstile for bot protection on the link creation form
  • Plausible or Umami for your own marketing site analytics (both are open source and privacy-friendly, with Umami at around 36,900 GitHub stars and Plausible at around 26,600 as of 2026-05-30, so either has a healthy self-host community if you do not want to pay)
  • 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

All figures below were checked on 2026-05-30 against each vendor's pricing page.

Service Cost Free-tier limit
Cloudflare Workers (free) $0 100,000 requests/day
Cloudflare KV (free) $0 100,000 reads/day, 1 GB stored
Vercel Pro $20/seat/month includes $20 of usage credit
Neon Postgres (free) $0 0.5 GB/project, 100 compute-hours/month
Upstash Redis (free) $0 500K commands/month, 256 MB
Tinybird (free) $0 10 GB stored, 1,000 queries/day
Stripe $0 fixed 2.9% + $0.30 per online charge
Short domain (.co, .link, etc.) $5-15/year registrar dependent
Total fixed ~$20-21/month

If you add custom domain support via Cloudflare for SaaS, the first 100 custom hostnames are free and each additional one is $0.10/month, with no separate base fee.

Common Errors and Fixes

A few failure modes show up over and over when building this stack. Most trace back to a free-tier limit or the eventual-consistency behavior of KV.

  • KV write limit hit during a launch spike. The Workers free plan only allows 1,000 KV writes per day. If a burst of new-link creation (or a buggy "write on every redirect" path) crosses that, writes start failing while reads keep working. Fix by only writing to KV on link creation, never on redirect, and increment click counts in Redis or Tinybird instead. If you genuinely need more, the paid plan lifts the cap and bills writes at $5.00 per million.
  • New short link 404s for the first minute. KV is eventually consistent, with updates propagating globally in roughly 60 seconds. A link can read as missing at one edge right after creation. Treat PostgreSQL as the source of truth and fall back to a Postgres lookup when KV misses, then warm KV on that path.
  • Workers daily request limit exceeded. Crossing 100,000 requests/day on the free plan returns errors until the 00:00 UTC reset. If a single link goes viral, move to the paid Workers plan rather than rationing redirects.
  • Vercel Pro bill higher than expected. Pro is $20 per seat per month and bundles $20 of usage credit, but bandwidth and function execution beyond that bundle bill as overage. Keep the high-traffic redirect path on Cloudflare Workers, not on Vercel functions, so your viral links never touch Vercel metering.
  • Neon connection errors after idle. Neon's free tier scales compute to zero after a short idle window, so the first query after a quiet period can be slow or briefly error while the compute wakes. Use a pooled connection string and add a retry on the cold first query.

Sources

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.

Built by Kevin

Like this? You'll like what I'm building too.

Two ways to support and get more of this work.

Desktop App

HEARTH

A privacy-first Life OS for your desktop. Journal, tasks, and notes that stay on your machine. Coming soon, direct download from this site.

Read more
Digital Products

MY TOOLKITS

Receipts-first toolkits for shipping after hours, building Claude agents, publishing on Amazon, and more. The exact methods I used, not theory.

Browse on Whop

Need This Built?

Kevin builds products solo, from first version to live. If you want something like this made, work with him.