/ build-guides / How to Build a URL Shortener as a Solo Developer
build-guides 9 min read

How to Build a URL Shortener as a Solo Developer

Step-by-step guide to building a URL shortener by yourself. Tech stack, timeline, costs, and practical advice.

Hero image for How to Build a URL Shortener as a Solo Developer

What You're Building

A URL shortener takes long URLs and converts them to short, shareable links. But the real product isn't the shortening. It's the analytics. Who clicked, when, from where, which device. That data is what businesses pay for. Modern link shorteners like Dub.co, Short.io, and Bitly are really analytics and link management platforms that happen to shorten URLs.

This is a great solo developer project because the core functionality is simple (a redirect with a database lookup), but the analytics layer adds real value and monetization potential.

Difficulty & Timeline

Aspect Detail
Difficulty Easy
Time to MVP 1-2 weeks
Ongoing Maintenance Low
Monetization Freemium subscription (free tier + paid analytics/custom domains)

For the redirect service, you want something fast. Really fast. Every redirect adds latency between the user clicking and reaching the destination. I'd use Cloudflare Workers for the redirect layer. It runs at the edge, globally, with sub-millisecond startup. You deploy with the Wrangler CLI (wrangler, currently v4.95.0 on npm and pulling roughly 20.3 million weekly downloads, so you are on a very well-trodden path). For the dashboard and API, use Next.js (currently v16.2.6, around 40.1 million npm downloads a week) on Vercel. PostgreSQL on Supabase handles link storage and analytics data, with @supabase/supabase-js at v2.106.2.

If you don't want to deal with Cloudflare Workers, a simple Next.js API route with a Redis cache for popular links works fine too. The redirect just needs to be fast.

Pin your versions when you start so a future npm install does not silently jump a major release on you. The numbers above were checked on 2026-05-30, so confirm the current release before you scaffold.

# Cloudflare Workers redirect service
npm create cloudflare@latest url-shortener
cd url-shortener
npx wrangler@4.95.0 dev          # local dev
npx wrangler@4.95.0 deploy       # ship to the edge

# Next.js dashboard + API
npx create-next-app@16.2.6 dashboard

# Supabase client + charting in the dashboard
npm install @supabase/supabase-js@2.106.2
npm install recharts@3.8.1       # or: npm install chart.js@4.5.1

Step-by-Step Plan

Phase 1: Foundation (Week 1)

Build the core redirect logic first. A user creates a short link, and when someone visits that link, your server looks up the destination URL in the database and returns a 301 redirect. That's the whole thing at its simplest.

Generate short codes using a combination of random characters. 6-7 characters gives you billions of unique combinations. Store the mapping in PostgreSQL. Add a Redis cache in front of it for frequently accessed links.

Build a simple dashboard where users can create links, see a list of their links, and view basic click counts. Authentication with Supabase Auth keeps things simple.

Phase 2: Core Features (Week 2)

This is where your URL shortener becomes a real product. Add click analytics. On every redirect, log the timestamp, referrer, country (from IP geolocation), device type, and browser. This click data is what users actually pay for.

Build an analytics dashboard for each link. Show clicks over time (line chart), top countries (bar chart), device breakdown (pie chart), and top referrers. Libraries like Recharts or Chart.js make this straightforward. Recharts (v3.8.1, 27.2k GitHub stars, around 46.9 million npm downloads a week) is the React-native choice and slots straight into a Next.js dashboard. Chart.js (v4.5.1, 67.5k GitHub stars, around 11.5 million weekly downloads) is the framework-agnostic option if you ever move off React. Both are checked-on figures from 2026-05-30.

Add custom slugs. Instead of yourapp.co/x7k9q, let users create yourapp.co/my-product. This is a premium feature people love.

Add UTM parameter tracking. Marketing teams live and die by UTM tags, and showing UTM data in your analytics dashboard makes your tool genuinely useful for marketers.

Phase 3: Polish & Launch (Week 2-3)

Add custom domain support. This is the killer premium feature. Users bring their own domain (links.theircompany.com) and all their short links use it instead of yours. Technically, this means adding their domain to your Cloudflare account and handling DNS verification. It's a bit of work to set up, but it's the feature that justifies premium pricing.

Build a simple API so users can create links programmatically. Many businesses integrate link shortening into their workflows. A REST API with API key auth covers this.

Create a landing page, add a "try it free" demo that lets people shorten a link without signing up, and launch.

Monetization Strategy

The freemium model works perfectly here. Give away basic link shortening for free (with your domain, limited analytics). Charge for the features businesses need.

Free tier. 50 links, basic click counts, your branded domain. This gets users in the door.

Pro tier ($9-19/month). 1,000 links, full analytics (geographic data, device data, referrers), custom slugs, API access.

Business tier ($29-49/month). Unlimited links, custom domains, team access, export data, priority support.

Dub.co has proven this model works at scale in the solo/small-team space. They're open source (around 23.6k GitHub stars as of 2026-05-30), which means you can study their approach directly. But there's room for competitors who focus on specific niches (e-commerce link tracking, podcast link analytics, etc.).

The math works partly because the underlying infrastructure stays cheap until you have real volume. Pricing checked on 2026-05-30:

Platform Free tier First paid tier
Cloudflare Workers (redirects) 100,000 requests per day, 10 ms CPU per invocation $5/month minimum, 10 million requests included, $0.30 per additional million
Vercel (dashboard + API) Hobby plan, free Pro at $20 per user per month
Supabase (Postgres + auth) 500 MB database, 50,000 monthly active users, 2 projects Pro at $25/month, 8 GB disk, 100,000 monthly active users, 250 GB egress

So a solo build can run for $0 while you validate, and your floor once you outgrow the free tiers is roughly $50/month across all three. That is the gap between a Pro subscriber's monthly fee and your cost base, which is the whole reason the freemium model survives. Confirm current pricing before you model your margins, since these tiers change.

Common Mistakes to Avoid

Slow redirects. If your redirect adds noticeable latency, users will stop using your service. Cache hot links in Redis. Use edge computing (Cloudflare Workers) if possible. The redirect should feel instant.

No abuse prevention. URL shorteners get abused for phishing and spam constantly. Implement basic URL scanning (check against the Google Safe Browsing API, which is free to use), rate limit link creation, and have a way to disable malicious links quickly. One thing to plan for now: the Safe Browsing v4 API is scheduled to be retired on 2027-03-31, so build against v5 if you are starting fresh rather than wiring up the deprecated version.

Storing too much personal data. Click analytics are valuable, but be careful with privacy regulations. Don't store full IP addresses (truncate or hash them). Make sure your privacy policy covers what you collect. GDPR and similar laws apply.

Competing on "more free links." Bitly already offers free link shortening. You won't win by being "Bitly but more free." Win by offering better analytics, easier custom domains, or focusing on a specific use case that Bitly doesn't serve well.

Common Errors and Fixes

A few snags hit almost everyone building this stack. These are grounded in the official docs for each platform.

Wrangler deploy fails with an authentication error. Before wrangler deploy works you have to be logged in. Run wrangler login (it opens a browser OAuth flow) or set a CLOUDFLARE_API_TOKEN environment variable for CI. The Cloudflare Workers docs cover both paths; the token route is what you want for any automated deploy.

Redirect Worker exceeds the CPU limit on the free plan. The Workers free plan caps you at 10 milliseconds of CPU time per invocation. A redirect is well under that if you keep the hot path lean, but heavy synchronous work (large JSON parsing, crypto in the request path) can trip it. Move analytics writes off the critical path with event.waitUntil() so the redirect returns immediately and the logging happens after.

Supabase queries return empty or permission-denied results. Supabase enables Row Level Security by default on new tables, so a freshly created table returns nothing through the public client until you add policies. Write explicit RLS policies for your links and clicks tables, or use the service-role key only on the server side. Do not ship the service-role key to the browser.

Next.js build breaks after a major version bump. Next.js moves fast (v16.2.6 at the time of writing), and major versions drop or change APIs. Pin the version in package.json rather than using a caret range that auto-jumps majors, and read the upgrade guide in the Next.js docs before bumping. The same applies to Recharts, which went through a v3 rewrite that changed several component props.

Counting clicks twice. Browsers and link-preview bots both hit your redirect, and some clients prefetch. If your numbers look inflated, filter known bot user agents and consider only counting a click once per short window per IP hash. This also keeps you on the right side of the privacy rules above, since you are hashing rather than storing raw IPs.

Is This Worth Building?

As a learning project, absolutely. A URL shortener touches redirects, caching, analytics, geolocation, charting, custom domains, and API design. You'll learn a ton.

As a business, it's viable but competitive. The link management space has established players (Bitly, Rebrandly, Dub.co). To succeed, you need a specific angle. Maybe it's the best link shortener for podcasters, or the cheapest option for small businesses, or the most privacy-focused alternative.

The total addressable market is large. Every business that shares links online is a potential customer. If you can carve out a niche and provide a great product, $2,000-5,000/month is realistic within a year.

Sources

All figures checked on 2026-05-30.

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.