Installation
Usage
Transform regular links into rich preview links that show website information on hover.Features
Rich Metadata Extraction
Automatically fetches and displays:- Site name: From og:site_name meta tag
- Title: Page title or og:title
- Description: Meta description
- Featured image: og:image or twitter:image
- Favicon: Site icon
Lazy Loading
Metadata only fetches when the link scrolls into view:- Uses Intersection Observer API
- Starts fetching 100px before element is visible
- Improves performance for pages with many links
Smart URL Validation
Only shows previews for valid HTTP/HTTPS URLs:Loading States
Graceful loading and error handling:Custom Styling
Override the default link appearance:Inline Usage
Works naturally in text:Props
Metadata Extraction
The component extracts metadata using multiple strategies:Priority Order
- Open Graph tags (og:title, og:description, og:image)
- Twitter Card tags (twitter:title, twitter:description, twitter:image)
- Standard HTML tags (title, meta description)
- Fallbacks (domain name, favicon.ico)
Supported Meta Tags
CORS Considerations
The component fetches URLs directly from the browser. Some sites may block cross-origin requests. For production:- Proxy through your backend:
- Use a metadata service:
Tooltip Positioning
The tooltip uses shadcn/ui’s Tooltip component:- Automatically positions to avoid viewport edges
- Maximum width of 280px
- Dark theme with zinc colors
- 3px padding for compact display
Performance
- Intersection Observer: Only fetches when link is near viewport
- Cached requests: Browser caches repeated fetches
- Lazy metadata: No impact on initial page load
- Image optimization: Uses Next.js Image component
Accessibility
- Opens in new tab with
target="_blank" - Includes
rel="noopener noreferrer"for security - Tooltip provides additional context for screen readers
- Link remains fully keyboard accessible
- Fallback text shown when preview unavailable