Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A self-hosted URL shortener with click tracking and referrer analytics, built with SvelteKit and Turso.
SvelteKit Short URLs is a self-hosted URL shortener template built with SvelteKit and Turso (libSQL) that creates short links and tracks clicks and referrer traffic.
SvelteKit Short URLs is a web application for running your own link-shortening service. It stores a source path (the short key) and a destination URL in a Turso database, then redirects visitors from the short link to the target while recording each click. The template runs on SvelteKit, a full-stack framework for Svelte, and is configured for deployment to Vercel. Its GitHub repository includes the source code, SQL schema, and development tooling.
links table holds source and destination columns; a request to a short path triggers a redirect to the stored destination.clicks counter on each link increments with every redirect, and the sample SQL queries can return the most-clicked links.referrers table records each traffic source per link and maintains a visit count per referrer, with an aggregation query for top referrers.visible flag to control which links appear.position column used for ordering in the interface.TURSO_DB_URL and TURSO_DB_AUTH_TOKEN, with an optional TURSO_SYNC_URL.links with a source key and destination URL, then share the short path.SELECT source, destination, clicks FROM links ORDER BY clicks DESC LIMIT 10; to see your most-clicked links.visible boolean to show or hide links in the web interface.Setup requires a Turso database. After creating one, you set the environment variables, install dependencies with pnpm install, and start development with pnpm dev. The project also includes tests run with pnpm test. Links are managed through SQL operations; the README documents exact INSERT, UPDATE, DELETE, and SELECT statements.
The template uses Turso, which is a libSQL database. You must provide TURSO_DB_URL and TURSO_DB_AUTH_TOKEN to connect.
Yes. The referrers table stores the referrer URL and a count of visits per link. A provided SQL query sums these counts to return the top referrers.
You insert a record into the links table with a source path, destination URL, description, visibility flag, and position. The repository includes the exact SQL statement for this.
TURSO_DB_URL (the database URL) and TURSO_DB_AUTH_TOKEN (the auth token) are required. TURSO_SYNC_URL is optional.
Install dependencies with pnpm install, then run pnpm dev. The project also has tests invoked with pnpm test.
