JSPM

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

Framework-friendly embed cards for YouTube, X, Reddit, Google Maps, Vimeo, and custom providers.

Package Exports

  • embed-card
  • embed-card/manual
  • embed-card/web-component

Readme

embed-card

embed-card is a small frontend package for turning a URL into a polished embed card with one install.

Install

pnpm add embed-card

React usage

import { EmbedCard } from "embed-card"

export function ArticleEmbed() {
  return (
    <EmbedCard url="https://www.youtube.com/watch?v=dQw4w9WgXcQ" />
  )
}

Theme the card

import { EmbedCard } from "embed-card"

export function BrandedEmbed() {
  return (
    <EmbedCard
      url="https://vimeo.com/76979871"
      theme={{
        accentColor: "#e11d48",
        radius: 28,
      }}
    />
  )
}

Web component usage

import { registerEmbedCard } from "embed-card/web-component"

registerEmbedCard()
<embed-card
  url="https://www.google.com/maps?q=Tokyo+Station&output=embed"
  accent-color="#0f766e"
></embed-card>

Low-level manual usage

import { resolveEmbed } from "embed-card/manual"

const embed = resolveEmbed("https://x.com/vercel/status/1808506503694602450")

Built-in providers

  • YouTube
  • X / Twitter
  • Reddit
  • Google Maps
  • Vimeo
  • Fallback link preview

Custom providers

import {
  EmbedCard,
  createEmbedProvider,
  defaultProviders,
} from "embed-card"

const customProvider = createEmbedProvider({
  id: "docs",
  label: "Docs",
  accentColor: "#7c3aed",
  match: (url) => url.hostname === "docs.example.com",
  resolve: (url) => ({
    provider: "docs",
    providerLabel: "Docs",
    accentColor: "#7c3aed",
    title: "Documentation page",
    description: "Custom providers plug into the same normalized contract.",
    site: url.hostname,
    url: url.toString(),
    displayUrl: url.toString(),
    renderer: {
      type: "link",
      href: url.toString(),
      ctaLabel: "Open docs",
    },
  }),
})

<EmbedCard
  providers={[customProvider, ...defaultProviders]}
  url="https://docs.example.com/platform/embeds"
/>