react-share: accessible social sharing buttons for React
Social media share buttons and share counts for React
At a glance
- What is it?
- react-share provides network-specific share buttons and icons, URL-building helpers, and a native share button for React applications. The current README documents version 6 for React 18 and 19.
- Who is it for?
- Use react-share when a React application needs customizable share buttons without loading network SDKs. Check the network-specific props and migration guide before upgrading from version 5.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 44 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- nygardk/react-share2,821 ★ · +6
| Repository | 2026-10-04 | 2026-11-25 |
|---|---|---|
| nygardk/react-share | 2.8k | 2.8k |
6 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What react-share provides
react-share supplies named React button and icon exports for social networks and email. The README also documents URL-building helpers and a native share button using the browser Web Share API. Network buttons generally open a share page in a popup, and no network SDK script is required. The current README describes version 6 as supporting React 18 and 19; consult its version table for older releases.
Install and create a share button
Install the package with `npm install react-share`. Import a button and icon, provide the page URL, and label an icon-only control. For example:
import { XShareButton, XIcon } from "react-share";
<XShareButton url="https://example.com/article" text="Read this next" aria-label="Share on X">
<XIcon size={32} />
</XShareButton>`text` is the X-specific share text. `htmlTitle` sets the native button title attribute; use an explicit accessible name as recommended by the project.
Network-specific props and email
The README lists supported services and their individual props. For example, Pinterest requires `media`, while Facebook Messenger requires `appId`; X uses `text`, and several other services use `shareTitle` or `message`. EmailShareButton uses `mailto:` and accepts `to`, `subject`, `body`, and `separator`; popup-only settings do not apply. Consult the current network table before implementing a button.
Popup behavior and mobile handoff
Popup-based buttons expose window dimensions, position and open/close callbacks. `onShareWindowOpen` receives null if a popup was blocked, allowing an application to offer a fallback. Selected messaging buttons also support `mobileBehavior` values `web`, `app`, and `auto`; test the desired behavior on your target devices.
Native sharing and accessibility
NativeShareButton uses `navigator.share()` where available and is disabled when native sharing is unavailable. File-sharing support depends on browser capabilities, which can be checked using `navigator.canShare()`. Pass `aria-label` or `aria-labelledby` for icon-only buttons; mark purely decorative standalone icons appropriately. Test keyboard and screen-reader behavior in the application itself.
URL helpers and customization
The package documents a `build*ShareUrl` helper for each network button. These helpers can build a share URL when a custom interaction is needed. Buttons and icons are separate exports, and button children can be replaced with your own icon or text. Check each helper’s network-specific parameters before use.
Versioning and verification
The README provides a v5-to-v6 migration guide and a compatibility table. Pin a tested package version, review changes in share payload props before upgrading, and verify each service’s current sharing flow. The README links a deployed demo and gives local development instructions; network sites and browser popup policies can change independently of the package.
Editorial conclusion
Use react-share when a React application needs customizable share buttons without loading network SDKs. Check the network-specific props and migration guide before upgrading from version 5. Give icon-only controls an explicit accessible name, and test popup blocking, mobile handoff and the native share sheet on target browsers.
Frequently asked questions
How do I install react-share?
Run `npm install react-share`. The current README says react-share 6 supports React 18 and 19 and links a migration guide for users upgrading from version 5.
How do I label an icon-only share button?
Pass `aria-label` or `aria-labelledby` to the share button. The README recommends an explicit accessible name for icon-only controls.
How do XShareButton and htmlTitle differ?
For XShareButton, `text` supplies share text, while `htmlTitle` sets the underlying button’s native title attribute. Use an explicit accessible name as well.
Does react-share support native sharing?
Yes. NativeShareButton uses the browser Web Share API and disables itself when native sharing is unavailable. The README also documents capability checks for sharing files.
How does email sharing work?
EmailShareButton uses a mailto: navigation instead of a popup. It accepts options including recipient, subject, body and separator; popup-only props do not apply.
Official sources
Was this useful?