npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

social-media-previews

v0.0.6

Published

React components for social media platform previews

Readme

Social Media Previews

A React component library for rendering social media platform previews. Perfect for social media management tools, content scheduling apps, or any application that needs to show how posts will appear across different platforms.

🎨 Try it live: See these components in action at Social Mocker - a free web app that lets you create pixel-perfect social media post mockups with customizable content and export them as high-resolution images.

Features

  • 🎨 Multi-platform support: Facebook, Twitter, Instagram, LinkedIn, and Bluesky
  • 🌓 Theme support: Light and dark modes for all platforms
  • 📱 Responsive design: Optimized layouts that match each platform's design
  • 🔧 TypeScript ready: Full TypeScript support with type definitions
  • 🎯 Zero dependencies: Only requires React as a peer dependency
  • Lightweight: Minimal bundle size with tree-shaking support

Installation

npm install social-media-previews

Platform Previews

| Platform | Light Mode | dark Mode | |----------|------------| ------------| | Facebook | | | | Twitter/X | | | | Instagram | | | | LinkedIn | | | | Bluesky | | |

Quick Start

The primary way to use this library is through the SocialMediaPreview component:

import { SocialMediaPreview, FacebookFormValues } from 'social-media-previews';

const MyComponent = () => {
  const facebookData: FacebookFormValues = {
    fullName: "John Doe",
    postText: "Check out this amazing content!",
    profilePicture: "https://example.com/avatar.jpg",
    postImages: ["https://example.com/image1.jpg"],
    likeCount: 42,
    commentCount: 8,
    shareCount: 3,
    timestamp: new Date().toISOString(),
    verified: true
  };

  return (
    <SocialMediaPreview
      platform="facebook"
      theme="light"
      values={facebookData}
    />
  );
};

Props Documentation

SocialMediaPreview Props

The main component accepts a discriminated union of props based on the platform:

| Prop | Type | Description | |------|------|-------------| | platform | "facebook" \| "twitter" \| "instagram" \| "linkedin" \| "bluesky" | The social media platform to render | | theme | "light" \| "dark" | The theme mode for the preview | | values | Platform-specific values object | Data to display in the preview |

Platform-Specific Value Types

FacebookFormValues

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | fullName | string | ✅ | - | User's display name | | postText | string | ❌ | - | The post content text | | profilePicture | string | ❌ | - | URL to profile picture | | postImages | string[] | ❌ | - | Array of image URLs | | likeCount | number | ❌ | 0 | Number of likes | | commentCount | number | ❌ | 0 | Number of comments | | shareCount | number | ❌ | 0 | Number of shares | | viewCount | number | ❌ | 0 | Number of views | | timestamp | string | ❌ | Current time | ISO timestamp | | verified | boolean | ❌ | true | Verification badge |

TwitterFormValues

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | displayName | string | ✅ | - | User's display name | | handle | string | ✅ | - | Twitter handle (must start with @) | | tweetText | string | ✅ | - | The tweet content | | profilePicture | string | ❌ | - | URL to profile picture | | postImages | string[] | ❌ | - | Array of image URLs | | likeCount | number | ❌ | 0 | Number of likes | | commentCount | number | ❌ | 0 | Number of replies | | retweetCount | number | ❌ | 0 | Number of retweets | | viewCount | number | ❌ | 0 | Number of views | | timestamp | string | ❌ | Current time | ISO timestamp | | verified | boolean | ❌ | true | Verification badge |

InstagramFormValues

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | username | string | ✅ | - | Instagram username | | fullName | string | ✅ | - | User's full name | | caption | string | ❌ | - | Post caption | | location | string | ❌ | - | Location tag | | profilePicture | string | ❌ | - | URL to profile picture | | postImages | string[] | ❌ | - | Array of image URLs | | likeCount | number | ❌ | 0 | Number of likes | | commentCount | number | ❌ | 0 | Number of comments | | timestamp | string | ❌ | Current time | ISO timestamp | | verified | boolean | ❌ | true | Verification badge |

LinkedInFormValues

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | fullName | string | ✅ | - | User's full name | | headline | string | ❌ | - | Professional headline | | postText | string | ✅ | - | Post content | | profilePicture | string | ❌ | - | URL to profile picture | | postImages | string[] | ❌ | - | Array of image URLs | | likeCount | number | ❌ | 0 | Number of likes | | commentCount | number | ❌ | 0 | Number of comments | | repostCount | number | ❌ | 0 | Number of reposts | | timestamp | string | ❌ | Current time | ISO timestamp | | verified | boolean | ❌ | true | Verification badge |

BlueskyFormValues

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | displayName | string | ✅ | - | User's display name | | handle | string | ✅ | - | Bluesky handle | | postText | string | ✅ | - | Post content | | profilePicture | string | ❌ | - | URL to profile picture | | postImages | string[] | ❌ | - | Array of image URLs | | likeCount | number | ❌ | 0 | Number of likes | | commentCount | number | ❌ | 0 | Number of replies | | repostCount | number | ❌ | 0 | Number of reposts | | shareCount | number | ❌ | 0 | Number of shares | | timestamp | string | ❌ | Current time | ISO timestamp | | verified | boolean | ❌ | true | Verification badge |

Using Individual Platform Components

While SocialMediaPreview is the recommended approach, you can also import and use individual platform components:

import { 
  FacebookPreview, 
  TwitterPreview, 
  InstagramPreview, 
  LinkedInPreview, 
  BlueskyPreview,
  type FacebookFormValues 
} from 'social-media-previews';

// Using individual components
const MyFacebookPreview = () => {
  const data: FacebookFormValues = {
    fullName: "John Doe",
    postText: "Hello World!"
  };

  return <FacebookPreview theme="light" values={data} />;
};

const MyTwitterPreview = () => {
  const data: TwitterFormValues = {
    displayName: "John Doe",
    handle: "@johndoe",
    tweetText: "Hello Twitter!"
  };

  return <TwitterPreview theme="dark" values={data} />;
};

Examples

Basic Usage with Different Platforms

import { SocialMediaPreview } from 'social-media-previews';
import type { 
  FacebookFormValues, 
  TwitterFormValues, 
  InstagramFormValues 
} from 'social-media-previews';

// Facebook Example
const facebookPost: FacebookFormValues = {
  fullName: "Tech Company",
  postText: "We're excited to announce our new product launch! 🚀",
  likeCount: 156,
  commentCount: 24,
  shareCount: 8,
  verified: true
};

// Twitter Example  
const tweet: TwitterFormValues = {
  displayName: "Tech Company",
  handle: "@techcompany",
  tweetText: "Just shipped a major update to our platform! Here's what's new:",
  likeCount: 89,
  retweetCount: 34,
  commentCount: 12
};

// Instagram Example
const instagramPost: InstagramFormValues = {
  username: "techcompany",
  fullName: "Tech Company",
  caption: "Behind the scenes at our office 📸 #techlife #innovation",
  location: "San Francisco, CA",
  likeCount: 234,
  commentCount: 18
};

const App = () => {
  return (
    <div className="space-y-8">
      <SocialMediaPreview 
        platform="facebook" 
        theme="light" 
        values={facebookPost} 
      />
      
      <SocialMediaPreview 
        platform="twitter" 
        theme="dark" 
        values={tweet} 
      />
      
      <SocialMediaPreview 
        platform="instagram" 
        theme="light" 
        values={instagramPost} 
      />
    </div>
  );
};

With Images

const postWithImages: FacebookFormValues = {
  fullName: "Travel Blogger",
  postText: "Amazing sunset from my latest adventure! 🌅",
  postImages: [
    "https://example.com/sunset1.jpg",
    "https://example.com/sunset2.jpg",
    "https://example.com/sunset3.jpg"
  ],
  likeCount: 89,
  commentCount: 15,
  profilePicture: "https://example.com/profile.jpg"
};

<SocialMediaPreview 
  platform="facebook" 
  theme="light" 
  values={postWithImages} 
/>

TypeScript Support

The library is written in TypeScript and provides full type support:

import type { 
  GeneralPreviewProps,
  FacebookFormValues,
  TwitterFormValues,
  InstagramFormValues,
  LinkedInFormValues,
  BlueskyFormValues 
} from 'social-media-previews';

// Type-safe platform switching
const renderPreview = (platform: string, data: any) => {
  switch (platform) {
    case 'facebook':
      return <SocialMediaPreview platform="facebook" theme="light" values={data as FacebookFormValues} />;
    case 'twitter':
      return <SocialMediaPreview platform="twitter" theme="light" values={data as TwitterFormValues} />;
    // ... other platforms
  }
};

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - See LICENSE file for details.