The OgCard component displays rich link previews for URLs by fetching and rendering Open Graph metadata. It's perfect for showcasing external links with preview images, titles, and descriptions.
Instead of fetching Open Graph data from a URL, you can directly provide the data to display.
The OgCard component supports different layout directions.
The OgCard component supports different sizes.
You can hide each element of the OgCard component by setting its prop value to false.
The OgCard extends the Card component, so you can use all Card props to customize its appearance.
To use OgCard with automatic Open Graph fetching, your application must expose two routes: one that fetches a page's metadata, and one that serves its image from your origin. In a Next.js app, both are ready-made in @once-ui-system/core/next, with SSRF protection built in:
See OG route handlers for their options. Outside Next.js, build the routes on handleOGFetch and handleOGProxy.
OgCard calls /api/og/fetch and /api/og/proxy by default. If your routes live elsewhere, wrap the app in OgRoutesProvider:
The optional /api/og/generate route renders social images for Meta.generate; it is not needed by OgCard.
Use serviceConfig to point a single OgCard at custom API routes (it takes precedence over OgRoutesProvider) or to transform proxied image and favicon URLs. Pass pre-fetched data with ogData to skip the fetch entirely.
- The component automatically fetches favicons for the domain
- Images are proxied through an API endpoint to avoid CORS issues
- You can overwrite the default props by providing static values
- You can set any value to false to disable it