JSPM

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

Reserved package name

Package Exports

  • openlink
  • openlink/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openlink) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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