Documentation

linkpeek

Fast, safe link previews for TypeScript

Fetch a URL and extract typed Open Graph, Twitter Card, JSON-LD, favicon, and canonical metadata with one runtime dependency. Literal private and non-global addresses are blocked by default; platform fetch still owns final DNS resolution.

Install from npm View on GitHub

Install

npm install linkpeek

Requires Node.js 22 or newer. CI also covers Bun and Deno; the fetch-native API is designed for compatible edge runtimes.

Example

import { preview } from "linkpeek";

const result = await preview("https://example.com/article");

console.log(result.title);
console.log(result.description);
console.log(result.image);

Why linkpeek

  • One runtime dependency and no DOM implementation
  • A 30 KB fast default with early stream cancellation after the document head
  • Private and non-global address blocking before the initial request and every redirect
  • Typed ESM and CommonJS output for server and fetch-compatible edge runtimes

Presets

The default fast preset retains up to 30 KB, scans head metadata, and cancels the response stream after the head when possible. Use presets.quality when body JSON-LD, a body-image fallback, or one validated meta-refresh is worth the additional work.

import { preview, presets } from "linkpeek";

const result = await preview(url, presets.quality);

Server-side use

Keep preview() behind a server or edge endpoint. Cache successful results, never forward caller credentials, and treat extracted metadata as untrusted content.