NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

Link Expander Template

  • Next.js
  • TypeScript

See where any short link really goes before you tap it: every redirect, the real destination and its domain.

A Next.js app that expands short links. Paste a bit.ly, t.co, youtu.be or any other link and see the page it really lands on, how many redirects it took and the destination’s domain, with buttons to open or copy the real link. Use it to check links before you click them, or lift the API route to unwrap links in your own app or moderation queue.

The link expander app running

What it does

The real destination
Follows the link to where it ends up and shows the full URL, with the domain picked out so lookalikes stand out.
Every redirect
Counts the redirects it followed, and on paid plans draws each hop in between as a chain.
Recent links
Keeps your last eight lookups on the device, so you can reopen one without spending a call.
Shareable results
Add ?url= to the page address to expand a link on load, handy for bookmarks and support replies.
Keeps your key private
The browser only talks to your own API route, which checks the link, caches answers and limits each visitor to 10 lookups a minute.

How it works

The API route: it checks the link, answers from the cache when it can, and calls URL Unshortener.

app/api/expand/route.ts
/** GET /api/expand?url=...: follows a short link to where it really goes. */
export async function GET(request: Request) {
  let url = str(new URL(request.url).searchParams.get('url'), 2000);
  if (!url) return fail('Paste a link to expand');
  if (!/^https?:\/\//i.test(url)) url = `https://${url}`;
  try {
    new URL(url);
  } catch {
    return fail('That doesn’t look like a link');
  }

  const key = `expand:${url}`;
  const hit = fromCache<Expanded>(key, TTL_MS);
  if (hit) return Response.json(hit);

  const blocked = guard(request);
  if (blocked) return blocked;

  return respond(async () => {
    const data = await callApi<Expanded>('urlunshortener', { json: { url } });
    toCache(key, data);
    return data;
  });
}

See the whole file on GitHub →

Deploy it

  1. Get a free API key

    The free plan includes 200 credits a month, no card needed. Create your key.

  2. Deploy it

    Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for APIVERVE_API_KEY: paste your key there.

  3. Open your app

    Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.

Try the URL Unshortener API — the call this template makes

Request
POSTapi.apiverve.com/v1/urlunshortener
Body
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "source": "https://bit.ly/3k3j4",
    "destination": "http://www.allclimbing.com/archive/2009/09/climbing-video-alex-puccio-on-trice-v12/",
    "unshortened": true,
    "redirectCount": 1,
    "destinationDomain": "www.allclimbing.com",
    "redirectChain": [
      "https://bit.ly/3k3j4",
      "http://www.allclimbing.com/archive/2009/09/climbing-video-alex-puccio-on-trice-v12/"
    ]
  }
}

Build your own with URL Unshortener. Start with 200 free credits. One key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs