linkpeek vs link-preview-js
Compare linkpeek with link-preview-js: speed on large pages, install size, runtimes, SSRF defaults, and migrating getLinkPreview() to preview().
Both packages turn a URL into preview-card metadata on the server. link-preview-js can start from free text and has the strictest DNS checks on Node.js. linkpeek reads only the page head, installs small and runs on any runtime with fetch.
Measured side by side
| Metric | linkpeek 3.0.0 | link-preview-js 6.0.0 |
|---|---|---|
| 500 kB page, median | 2.76 ms | 48.6 ms |
| Small pages, mean of medians | 1.25 ms | 1.72 ms |
| Clean install size | 1.3 MB | 7.9 MB |
| Packages installed | 7 | 18 |
link-preview-js 6 refuses private addresses entirely, so it cannot reach a local benchmark server. Its numbers are native fetch plus getPreviewFromContent(). See the benchmarks for the method and every package.
Choose link-preview-js when
- You start from free text and need the first URL in it detected for you.
- You need the strictest built-in SSRF defense on Node.js: version 6 resolves every hostname and redirect hop with
dns.lookupand pins the connection to the checked addresses, which defeats DNS rebinding. linkpeek checks DNS answers on every hop only when you passresolveHost, and does not pin the connection.
Choose linkpeek when
- You run on Cloudflare Workers, Vercel Edge, Deno or Bun. linkpeek uses only platform
fetch, Web Streams andTextDecoder. - Your users paste links to large pages. linkpeek stops reading after
</head>and cancels the stream, so most of a 500 kB page is never downloaded or parsed. - Install size matters for cold starts or container images. linkpeek has one runtime dependency.
- You want a typed, flat result (
title,description,image,siteName,canonicalUrl,favicon) and typed error codes.
Migrate getLinkPreview() to preview()
// link-preview-js
import { getLinkPreview } from "link-preview-js";
const data = await getLinkPreview(url);
const card = {
title: data.title,
image: data.images?.[0],
favicon: data.favicons?.[0],
};
// linkpeek
import { preview } from "linkpeek";
const result = await preview(url);
const card = {
title: result.title,
image: result.image,
favicon: result.favicon,
};linkpeek resolves HTTP error pages with their metadata and a statusCode instead of throwing, so check result.statusCode < 400 before caching. Errors you should branch on carry a code such as PRIVATE_NETWORK_BLOCKED or TIMEOUT; the API reference lists them.
For a public preview endpoint on Node.js, pair linkpeek with outbound network rules, as the security model explains.
All libraries
Compare linkpeek with link-preview-js, open-graph-scraper, metascraper, unfurl.js, and url-metadata by use case, API shape, security, and footprint.
vs open-graph-scraper
Compare linkpeek with open-graph-scraper: speed on large pages, install size, edge runtime support, SSRF defaults, and how to migrate ogs() to preview().