URL Shortener

Paste a long URL and get a short, shareable link.

Long URL
Your Short URL
Recent Links
No links shortened yet.
All examples use BASE_URL — set it to your deployment URL.
POST/api/url/shorten
Create a shortened URL.
const BASE_URL = "http://localhost:3000"; const res = await fetch(`${BASE_URL}/api/url/shorten`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url: "https://github.com/long/repo/path" }) }); const data = await res.json(); // → { success: true, shortUrl: "http://localhost:3000/s/abc1234", id: "abc1234" }
GET/api/url/stats/:id
Get click stats for a shortened URL.
const res = await fetch(`${BASE_URL}/api/url/stats/abc1234`); const data = await res.json(); // → { success: true, url: "https://...", clicks: 42, createdAt: "..." }
GET/s/:id
Redirect to the original URL (use in browser).
// Simply open in browser or use as a link: window.open(`${BASE_URL}/s/abc1234`); // → 302 redirect to the original URL