OpenLink

Quick Start

Get started with OpenLink in under a minute.

bun add openlink
pnpm add openlink
npm install openlink

Import and use

import { preview } from "openlink"

const data = await preview("https://vercel.com")

Get your data

{
  title: "Vercel",
  description: "Develop. Preview. Ship.",
  image: "https://vercel.com/og-image.png",
  favicon: "https://vercel.com/favicon.ico",
  siteName: "Vercel",
  url: "https://vercel.com"
}

Framework Examples

app/api/preview/route.ts
import { preview } from "openlink"
import { NextRequest, NextResponse } from "next/server"

export async function GET(request: NextRequest) {
  const url = request.nextUrl.searchParams.get("url")

  if (!url) {
    return NextResponse.json({ error: "Missing url" }, { status: 400 })
  }

  const data = await preview(url)
  return NextResponse.json(data)
}
server.ts
import express from "express"
import { preview } from "openlink"

const app = express()

app.get("/preview", async (req, res) => {
  const { url } = req.query

  if (!url || typeof url !== "string") {
    return res.status(400).json({ error: "Missing url" })
  }

  const data = await preview(url)
  res.json(data)
})

app.listen(3000)
worker.ts
import { preview } from "openlink"

export default {
  async fetch(request: Request) {
    const url = new URL(request.url)
    const target = url.searchParams.get("url")

    if (!target) {
      return new Response("Missing url", { status: 400 })
    }

    const data = await preview(target)
    return Response.json(data)
  }
}

OpenLink works on any JavaScript runtime including Node.js, Bun, Deno, and edge functions.

On this page