A URL shortener with click analytics, built by Claude Code on Elements

A URL shortener with click analytics, built by Claude Code on Elements

Short links with custom back-halves and expiry dates, instant redirects, live click counts, referrer, country and device breakdowns, tags, search and QR codes.

View the code on GitHub →

How it's built

Shortwick needed short links that redirect at once, a click count that climbs while the owner watches, breakdowns by referrer, country and device, QR codes and accounts. Each of those is a part of Elements, so the agent spent its 18 minutes on the shortener itself.

  • Live click counts. Links are a LiveTable, one view per owner, and a trigger publishes each new count, so the dashboard's numbers climb as visitors click.
  • Links edited straight through the view. The dashboard creates, edits, switches off and deletes links through the live view itself. The table checks the owner, validates the url and back-half, and reports a taken back-half on the form.
  • Redirects first, counting after. A short link sends the visitor on their way, then stores the click and bumps the count in one transaction. Expired and switched-off links get their own page.
  • Analytics that update as clicks arrive. Each click also goes out on a channel, and a link's analytics page adds it to the chart and the referrer, country and device lists over 7, 30 or 90 days.
  • QR codes. Each link has a QR code served as a PNG, built with an npm package.
  • Data and sessions from SQL. Migrations define the shortener and seed two users, twenty links and three months of clicks, and each owner signs in with a session.

Why Elements

Elements is the integrated stack for building apps with AI: a TypeScript project server, build system, app framework and deployment system, engineered from the ground up as one. Your editor, tools and one or many agents all connect to the same always-on project server, which runs type checking, program analysis, migrations and tests as the agent builds. Built-in guardrails keep the app structured correctly and secure as it grows from prototype to production.

Run it yourself

Paste this into a terminal. It installs Elements, creates your copy of this app and starts it.

curl -fsSL 'https://elements.dev/install?create=shortwick&scaffold=demo-shortwick' | sh
View script