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.
npm install react-shareVerified import paths — ran on the pinned version, not inferred.
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`.
Remove all usage of share count exports (e.g., `getFacebookShareCount`). The library will no longer provide this functionality reliably.
Discontinue using `hashtags`, `related`, and `via` props with `ThreadsShareButton` as they have no effect and will be removed.
Add an `aria-label` attribute (e.g., `aria-label="Share on Facebook"`) to all icon-only share buttons to make them accessible.
Upgrade to `react-share@5.0.4` or newer. This version includes specific fixes to the `package.json` `exports` field to ensure better compatibility with both ESM and CJS environments.
Ensure that your project's installed React version (`react` and `react-dom`) satisfies the peer dependency range specified by your `react-share` version to prevent installation warnings or runtime issues.
Ensure you are using named imports correctly: `import { FacebookShareButton } from 'react-share';` rather than `import FacebookShareButton from 'react-share';`.For SSR applications, ensure `react-share` components that interact with the `window` object are rendered only on the client-side. For `EmailShareButton`, verify it's not being used in a context that expects a popup window behavior.
Upgrade to the latest `react-share` version (v5.x), as it includes build tooling updates to mitigate such issues. If using Webpack 5, you may need to manually add Node.js polyfills if your setup explicitly disables them.
Update `react-share` to version `5.0.4` or higher. This specific patch release addressed `exports` configuration issues, improving CommonJS compatibility.