React Social Share Buttons

5.3.0 · active · verified Sun Apr 19

react-share is a robust and actively maintained React component library, currently at stable version 5.3.0, designed for integrating social media share buttons and formerly, share count functionalities into web applications. It releases minor and patch updates frequently to add new platforms, resolve issues, and manage deprecations. A primary advantage of react-share is its complete independence from external social media SDKs, ensuring better performance and enhanced user privacy by eliminating third-party script loading. The library fully leverages ES modules for effective tree shaking, enabling developers to minimize bundle sizes by importing only the necessary components. It provides a comprehensive suite of share buttons for numerous platforms, including Facebook, X (formerly Twitter), LinkedIn, WhatsApp, Email, and newer additions like Bluesky and Threads, all of which typically open a popup share window. The package includes its own set of social media icons but also offers flexibility for using custom icon sets. It maintains broad compatibility with React versions 17, 18, and 19. Development is active on GitHub, accompanied by a detailed API for customizing button behavior, appearance, and accessibility.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate `react-share` buttons, including Facebook, X, and LinkedIn, along with their respective icons, into a React component. It also shows how to use custom children for buttons while ensuring accessibility with `aria-label`.

import React from 'react';
import {
  FacebookShareButton,
  XShareButton,
  LinkedinShareButton,
  FacebookIcon,
  XIcon,
  LinkedinIcon,
} from 'react-share';

const MyShareButtons = () => {
  const shareUrl = 'https://checklist.day';
  const title = 'Checklist Day - Your daily productivity companion';

  return (
    <div style={{ display: 'flex', gap: '10px' }}>
      <FacebookShareButton url={shareUrl} quote={title} hashtag="#productivity">
        <FacebookIcon size={32} round />
      </FacebookShareButton>

      <XShareButton url={shareUrl} title={title}>
        <XIcon size={32} round />
      </XShareButton>

      <LinkedinShareButton url={shareUrl} title={title}>
        <LinkedinIcon size={32} round />
      </LinkedinShareButton>

      {/* Example with custom children and accessibility */}
      <XShareButton url={shareUrl} title={title} aria-label="Share on X (formerly Twitter)">
        <span style={{ fontSize: '14px', padding: '8px', border: '1px solid #ddd', borderRadius: '5px' }}>
          Share on X
        </span>
      </XShareButton>
    </div>
  );
};

export default MyShareButtons;

view raw JSON →