# 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 |

Measured on November 15, 2026, same corpus and local server.

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](https://linkpeek.js.org/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.lookup` and pins the connection to the checked addresses, which defeats DNS rebinding. linkpeek checks DNS answers on every hop only when you pass `resolveHost`, 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 and `TextDecoder`.
- 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()

```ts
// 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](https://linkpeek.js.org/api/) lists them.

For a public preview endpoint on Node.js, pair linkpeek with outbound network rules, as the [security model](https://linkpeek.js.org/security/) explains.

Related: [Benchmarks](https://linkpeek.js.org/benchmarks/) · [All libraries](https://linkpeek.js.org/guides/link-preview-library-comparison/) · [vs open-graph-scraper](https://linkpeek.js.org/guides/open-graph-scraper-alternative/)
