JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 704
  • Score
    100M100P100Q61396F
  • License MIT

Edge-first link preview. Zero dependencies.

Package Exports

  • openlink

Readme

openlink

Edge-first link preview. Zero dependencies, ~6kb gzipped.

npm install openlink
import { preview } from 'openlink'

const data = await preview('https://github.com')

Returns { url, title, description, image, favicon, siteName, domain, type, contentType, lang, ... }

oEmbed

const data = await preview('https://youtube.com/watch?v=...', {
  includeOembed: true
})

console.log(data.oembed) // { provider, title, html, thumbnail, ... }

Supports YouTube, Vimeo, Twitter/X, Spotify, TikTok, Instagram, CodePen, CodeSandbox, Figma.

JSON-LD

const data = await preview('https://bbc.com/news', {
  includeJsonLd: true
})

console.log(data.jsonLd) // { types, article, product, organization, ... }

Retry

const data = await preview('https://example.com', {
  retry: 3,
  retryDelay: 1000
})

Cache

import { createCache, memoryCache, withCache, preview } from 'openlink'

const cache = createCache(memoryCache())
const cachedPreview = withCache(cache, preview)

const data = await cachedPreview('https://github.com')

Image Size

import { getImageSize } from 'openlink'

const size = await getImageSize('https://example.com/image.png')
console.log(size) // { width: 1200, height: 630, type: 'png' }

Works on Cloudflare Workers, Vercel Edge, Deno, Bun, and Node 18+.

Docs · API · TypeScript

MIT