Get Updates

Tweet Card

A versatile Tweet card component for displaying Twitter/X posts with support for videos, photos, and interactive elements.

Christer Hagen

Written by Christer Hagen

The Tweet Card component provides a beautiful way to display Twitter/X posts with support for videos, photos, and interactive elements. Perfect for showcasing social media content with a consistent design.

Installation

1. Install Dependencies

2. React Server Component Setup

Copy and paste the following code into your project:

3. Server Action Setup (Optional)

If you want to fetch tweets server-side, create a server action:

Make sure to update the import paths to match your project structure:

  • The cn utility should point to your utils file
  • Place the server action in your app/actions directory
  • Adjust the component's location based on your project organization

Examples

Basic Usage

X Icon Variant

Hidden Media

Compact Mode

Usage

Basic Tweet Card

X Icon Variant

Hidden Media

Compact Mode

Props

PropTypeDefaultDescription
idstringrequiredThe Twitter/X post ID
classNamestringundefinedAdditional classes for styling
compactbooleanfalseEnable compact mode
hideMediabooleanfalseHide photos and videos
iconVariant"twitter" | "x""twitter"Choose between Twitter or X icon

Features

  • Smooth loading animations
  • Video and photo support
  • Compact mode for space efficiency
  • Twitter/X icon variants
  • Like and reply interactions
  • Loading skeleton states
  • Error handling
  • Dark mode support
  • Responsive layout
  • Verified badge support
  • Media hiding option
  • Interactive hover states

Credits

This component was inspired by the excellent work of Steven Tey and his implementation in Dub.co.