Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a link preview in two layers: first obtain and normalize metadata for the destination URL, then render that data as an ordinary, accessible card. Keeping those responsibilities separate lets you change from a hosted extractor to your own server endpoint or cache without rewriting the React, Vue, Svelte, or Astro UI.

What a link preview component actually does

A preview card is page UI about another URL. It normally contains a destination link, title, description, optional image, and a site label or hostname. The component should receive this information as data and render it in the document body.

Do not confuse that card with document metadata. React’s built-in <meta> component writes metadata for the current document into the head. React’s <link> component is likewise intended for document links and metadata and is generally placed in the head. Neither element fetches metadata for an arbitrary URL entered by a visitor, nor does either render a visible preview card.

Define one metadata contract

Use one internal shape at the boundary between fetching and rendering. Fields are optional because remote pages can omit descriptions or images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
type LinkPreview = {
  requestedUrl: string;
  resolvedUrl?: string;
  title?: string;
  description?: string;
  imageUrl?: string;
  siteName?: string;
  hostname?: string;
};

type PreviewState =
  | { status: 'loading' }
  | { status: 'ready'; data: LinkPreview }
  | { status: 'error'; message: string };

Validate the submitted URL and escape untrusted strings at the boundary where they enter your application. Treat image and destination URLs as untrusted too: only permit schemes your application intends to support, normally https: (and http: if your product explicitly needs it). The contract above is implementation guidance, not a vendor-mandated schema.

Choose where metadata is fetched

Build-time Astro pages

In a statically generated Astro page, a component-level fetch() runs at build time and its result is available to the template. This is suitable when the set of preview URLs is known during the build. It will not refresh for every visitor, so rebuild when freshness matters.

Request-time server rendering

With Astro SSR enabled, the same component fetch can run for each request. Use this when metadata depends on request-time data or must be current, while accounting for origin latency and hosting/runtime cost.

Browser-triggered retrieval

A client component is appropriate when a user enters URLs interactively or when the card must refresh without navigation. Do not expose credentials for a private extraction service in browser code; call your own server endpoint instead.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hosted extraction

A hosted metadata service can handle extraction, redirects, caching, image handling, and framework integrations. Compare its response fields, cache behavior, privacy terms, and failure semantics with an application-owned endpoint before adopting it. A service is optional; the card contract should not depend on one provider.

Build a small server endpoint first

Centralizing retrieval gives every framework the same behavior. Your endpoint should accept a URL, validate it, fetch or call an extractor, map the response to LinkPreview, and return JSON. Add a short-lived cache keyed by normalized URL when repeated requests are expected. Return a useful error state for malformed input, unsupported content, timeouts, and pages with no usable metadata.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
// Example response from /api/link-preview?url=...
{
  "requestedUrl": "https://example.com/article",
  "resolvedUrl": "https://example.com/article",
  "title": "An example article",
  "description": "A short summary.",
  "imageUrl": "https://example.com/cover.jpg",
  "siteName": "Example",
  "hostname": "example.com"
}

Keep loading, error, and fallback states in the UI. A missing image should not remove the title or destination link. If title extraction fails, display the hostname or resolved URL rather than an empty card.

React: render data, not head metadata

A React card can be a pure component that receives a ready LinkPreview. Fetching can happen in a parent, a route loader, or a client effect that calls your server endpoint.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
export function LinkPreviewCard({ data }: { data: LinkPreview }) {
  const label = data.title || data.hostname || data.resolvedUrl || data.requestedUrl;
  return (
    <article className="preview-card">
      {data.imageUrl ? (
        <img src={data.imageUrl} alt="" loading="eager" />
      ) : null}
      <div>
        <p className="preview-site">{data.siteName || data.hostname}</p>
        <h3>
          <a href={data.resolvedUrl || data.requestedUrl}>{label}</a>
        </h3>
        {data.description ? <p>{data.description}</p> : null}
      </div>
    </article>
  );
}

export function PreviewState({ state }: { state: PreviewState }) {
  if (state.status === 'loading') return <p aria-live="polite">Loading preview…</p>;
  if (state.status === 'error') return <p role="alert">{state.message}</p>;
  return <LinkPreviewCard data={state.data} />;
}

Use React’s document-head APIs only for the page your application is rendering. The visible card belongs in normal body markup, with a real anchor so keyboard and assistive-technology users have a clear destination.

Vue: keep the card presentational

In Vue, pass the normalized object as a prop and let a parent composable or server-rendered route own retrieval. This keeps the card testable and makes loading/error handling consistent with the other frameworks.

<script setup>
defineProps({
  data: { type: Object, required: true }
})
</script>

<template>
  <article class="preview-card">
    <img v-if="data.imageUrl" :src="data.imageUrl" alt="" loading="eager" />
    <div>
      <p class="preview-site">{{ data.siteName || data.hostname }}</p>
      <h3>
        <a :href="data.resolvedUrl || data.requestedUrl">
          {{ data.title || data.hostname || data.requestedUrl }}
        </a>
      </h3>
      <p v-if="data.description">{{ data.description }}</p>
    </div>
  </article>
</template>

Render a separate loading element with an appropriate live-region or a concise error message. Avoid inserting remote HTML into the template; bind text and attributes so the framework escapes text content.

Svelte: use a typed prop and explicit fallbacks

Svelte’s component can accept the same object. Keep network work in a parent or endpoint rather than coupling the card to one retrieval provider.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<script lang="ts">
  export let data: LinkPreview;
</script>

<article class="preview-card">
  {#if data.imageUrl}
    <img src={data.imageUrl} alt="" loading="eager" />
  {/if}
  <div>
    <p class="preview-site">{data.siteName || data.hostname}</p>
    <h3>
      <a href={data.resolvedUrl || data.requestedUrl}>
        {data.title || data.hostname || data.requestedUrl}
      </a>
    </h3>
    {#if data.description}
      <p>{data.description}</p>
    {/if}
  </div>
</article>

If the card has no client interaction, render it on the server or as static HTML. Hydrate only when you need behavior such as refresh, dismissal, or an interactive URL picker.

Astro: compose static cards and framework islands

Astro can render React, Vue, and Svelte components. Astro components themselves produce static HTML; a framework component becomes an island when you add a client:* directive. The selected directive controls hydration timing, and the island adds the JavaScript required by that framework.

Fetch in an Astro component

---
const url = 'https://example.com/article';
const response = await fetch(`${Astro.url.origin}/api/link-preview?url=${encodeURIComponent(url)}`);
const preview = response.ok ? await response.json() : null;
---

{preview ? (
  <article class="preview-card">
    <h3><a href={preview.resolvedUrl || preview.requestedUrl}>{preview.title || preview.hostname}</a></h3>
    {preview.description && <p>{preview.description}</p>}
  </article>
) : (
  <p>Preview unavailable.</p>
)}

For static output, this fetch occurs at build time. With SSR, it can occur at request time. Pass serializable preview data as props when a framework island needs to render it.

---
import ReactPreview from '../components/ReactPreview.jsx';
const preview = { title: 'Example', hostname: 'example.com', requestedUrl: 'https://example.com' };
---

<ReactPreview client:visible data={preview} />

Only Astro components can contain components from multiple frameworks. Keep each React, Vue, or Svelte component in its own framework syntax. Use serializable props; when child content needs Astro’s server-rendered behavior, prefer Astro slots rather than expecting framework render props to provide Astro’s client runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Accessibility and visual behavior

  • Make the destination a real <a>, not a click handler on a <div>.
  • Use a meaningful heading level within the surrounding page outline.
  • Use alt="" for a purely decorative thumbnail; provide useful alternative text only when the image conveys information not present in the title.
  • Keep loading announcements concise and expose failures with role="alert" or a suitable live region.
  • Reserve image space with CSS to reduce layout movement, and constrain remote images with object-fit.
  • Show the hostname or URL when title metadata is absent, and omit empty description blocks.

Freshness, caching, and runtime trade-offs

Approach Freshness JavaScript and control Good fit
Astro build-time fetch Until the next build Minimal browser JavaScript; simple deployment Known URLs and mostly static content
Astro SSR fetch Per request, subject to your cache Server runtime and origin latency Current or request-dependent previews
Browser component calling your endpoint On interaction or refresh Hydration and client network request User-entered URLs and live updates
Hosted extractor Provider and your cache policy Less extraction code; external dependency Teams that prefer managed retrieval

Cache successful responses for a period that matches how often the source changes, and decide whether stale data is preferable to an empty card. Cache failures briefly so one unavailable origin does not create a request storm. Do not claim a universal latency or reliability advantage for any approach without measurements from your own URLs and runtime.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The card shows the current page’s title

You rendered document-head metadata instead of destination data. Fetch the submitted URL through your endpoint and pass its normalized response to the body component.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Every request fails in the browser

The destination may reject cross-origin browser requests. Retrieve metadata server-side and return only the fields your card needs.

Some cards have no image

Remote pages can omit an image or expose an unusable URL. Treat the image as optional, reserve a text-only layout, and do not make the image request block the title.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Astro data is unexpectedly stale

The page is likely statically generated, so its component fetch ran at build time. Rebuild, enable SSR, or move refresh behavior to an island and your endpoint.

The island is too heavy

A static card does not need hydration. Render it in Astro, or choose a later hydration directive and reserve a framework island for interaction.

Users see malformed or unsafe links

Validate and normalize URLs before fetching, allow only intended schemes, escape text, and reject values that do not meet your product’s URL policy.

The extractor times out or returns a bot-check page

Return a bounded error state, preserve the destination link, and cache the failure briefly. A preview is an enhancement; navigation should still work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

ScreenshotNeo can provide a screenshot of a URL through one request, which is useful when your preview needs a visual snapshot rather than parsed text. Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing result in headers. Its MCP server gives AI agents tools such as take_screenshot, get_page_info, and capture_pdf.

See the ScreenshotNeo API documentation for the current parameters. cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to try it.

FAQ

Should a preview card use Open Graph tags from my own page?

Those tags describe the document containing them. A card about another URL still needs metadata retrieved for that destination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do all previews need a framework runtime?

No. A static Astro component or server-rendered HTML is enough when the card has no client interaction.

When should I use a hosted extractor?

Use one when managed extraction and documented integrations outweigh the control of operating your own endpoint. Confirm its fields, caching, image behavior, privacy terms, and current service conditions first.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.