The mechanics of a shortener are small: store a slug and a destination, answer with a redirect, log the click and draw a QR code. An agent can build that, with a click chart and CSV import for your Bitly export, in one sitting, and mature open-source shorteners already exist if you'd rather not build. What you actually buy from Bitly is permanence and reach: a domain people already trust, an uptime record, and links printed or posted years ago that must still resolve. Your own domain removes the lock-in, but it also makes you the one who keeps the redirect alive.
Before you buildIf you only need a handful of links a month and don't mind the ads, Bitly Free (5 links) may be enough. Branded links are the reason to pay.
Build me a self-hosted link shortener with click stats to replace Bitly. Requirements: - Node.js 22 + TypeScript: a Hono server on @hono/node-server. `npm start` serves on http://localhost:4800; the admin page is server-rendered HTML, no front-end framework. - Storage: better-sqlite3 in ./data/links.db: links (slug, url, created_at, expires_at, disabled) and clicks (link_id, ts, country, device, referrer_host, is_bot). - GET /<slug> answers 302 to the destination (or 410 for expired and 404 for unknown). Slugs are random 6-character base62 or a custom back-half; reject duplicates and reserve admin and api. - Destinations can be edited later without changing the slug. - Click log: country from the CF-IPCountry header or a MaxMind GeoLite2 file when GEOIP_DB is set (else "unknown"), device class from `ua-parser-js`, bots flagged with `isbot`. Store the referrer host only. Never store IP addresses or full user agents. - Admin at /admin behind one password in .env (signed cookie): create a link, list links with click totals, a per-link page with a 30-day bar chart drawn as inline SVG and tables of top countries, devices and referrers, and CSV export of links and clicks. - QR codes with `qrcode`: /admin/links/<slug>/qr.png and .svg, error correction level H. - CSV import (slug,url with a header row, so a Bitly export can be loaded): skip duplicates and list conflicts. - Single user. No accounts, no telemetry, local-first. Outbound calls: none. - Out of scope: team workspaces, link-in-bio pages, A/B redirects, managing DNS. - README: put it behind Caddy with HTTPS on your own domain, back up the SQLite file, and state plainly that links only work while this server and the domain stay alive.
Opens your agent with the prompt filled in, you press enter. Or copy it and paste it into an empty folder.
The first prompt builds the core. Run these one at a time in the same folder to grow it into your own Bitly.
Add a Bitly migration command to the shortener in this folder. Requirements: - `links import-bitly export.csv` reads the CSV from Bitly's Links > Export (columns for link, custom link, date created, title, destination URL and status). - Keep the original back-half as the slug, keep date created, skip links Bitly marks as deleted. - Print a table of imported, duplicate and invalid rows before writing anything; require --yes to apply. - A `links verify` command that requests every imported slug on localhost and reports any that don't redirect to the stored destination. - Update the README with the cut-over order: load links, verify, then repoint DNS.
Add a weekly digest to the shortener in this folder. Requirements: - Every Monday at 08:00 in TIMEZONE from .env, send one plain-text email through the SMTP settings in .env with the top 10 links by clicks in the last 7 days and the change versus the week before. - Leave bots out of the counts and say how many clicks were excluded. - A `links digest --now` command to preview it in the terminal. - Update the README.
Extend the shortener in this folder. Requirements: - An optional expires_at and max_clicks per link; after either, the slug answers 410 with a short page. - Saved UTM presets (source, medium, campaign) in a table; choosing a preset when creating a link appends the parameters to the destination without duplicating existing ones. - Show both settings on the link page and include them in the CSV export. - Update the README.
A short link is a promise to keep resolving for as long as the printed box, slide or post exists. Bitly sells that continuity plus shared workspaces and an admin trail, and marketing teams pay so they never have to ask engineering to change a redirect.
Estimate · A small VPS is about $5 a month, or nothing extra if you already run one. The domain costs what you already pay for it. The build is token usage on your agent plan.
| Plan | Monthly | Annual, per month | What you get |
|---|---|---|---|
| Free | $0/workspace | $0/workspace | 5 links, 2 QR codes, 2 landing pages and 3 custom back-halves a month; unlimited clicks and scans; no click history. |
| Core | — | $10/workspace | 100 links, 5 QR codes and 5 landing pages a month, 30 days of click data, UTM builder, link and QR redirects. |
| Growth | $35/workspace | $29/workspace | 500 links, 10 QR codes and 10 landing pages a month, branded links on a complimentary custom domain, 4 months of click data, bulk creation. |
| Premium | $300/workspace | $199/workspace | 3,000 links, 200 QR codes and 20 landing pages a month, 1 year of click data, city and device-level data, campaign tracking, mobile deep links. |
| Enterprise | custom | — | Custom link, QR code and landing-page volume, multiple users with group permissions, SSO, high-volume API access, 99.99% uptime. |
Free allows 5 links, 2 QR codes and 3 custom back-halves a month, with ads, no analytics history and no branded domain.
Yes. An AI coding agent such as Claude Code, Codex or Cursor can build a usable personal version in one session with the prompt on this page, running on your own machine.
About $35 a month on the Growth plan, $420 a year (checked 2026-10-14).
Bitly's own uptime record and the reputation of the bit.ly domain; Mobile deep links and campaign-level tracking; Bitly Pages, the link-in-bio and landing-page builder; Shared workspaces, group permissions and SSO; A hosted API that other tools already integrate with. If any of those matter to you, keep paying.
Yes: Dub (open source), Shlink (open source), YOURLS (open source).