Social media share buttons and share counts for React
Installations
npm install react-share
Developer
nygardk
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
20.9.0
NPM Version
10.1.0
Statistics
2,649 Stars
571 Commits
437 Forks
16 Watching
10 Branches
57 Contributors
Updated on 26 Nov 2024
Languages
TypeScript (98.12%)
JavaScript (1.88%)
Total Downloads
Cumulative downloads
Total Downloads
76,043,006
Last day
-0.7%
77,499
Compared to previous day
Last week
5.9%
441,176
Compared to previous week
Last month
4.5%
1,806,807
Compared to previous month
Last year
10.1%
21,237,655
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
1
Dev Dependencies
22
react-share
Social media share buttons and share counts for your React apps.
Install
1npm install react-share
Features
- no external script loading, i.e. no dependencies on SDKs
- supports tree shaking with ES modules
- opens a popup share-window
- share buttons for:
- Facebook Messenger
- X (formerly Twitter)
- Telegram
- VK
- Odnoklassniki
- Tumblr
- Mail.Ru
- LiveJournal
- Viber
- Workplace
- Line
- Instapaper
- Hatena
- Gab
- share counts for
- VK
- Odnoklassniki
- Tumblr
- Hatena
- social media icons included in the library
- supports also custom icons
Demo
-
Deployed demo (from
./demo
) -
Locally: clone the repository and run
npm install && npm run demo
.
React compatibility
Version | Compatible React versions |
---|---|
1 | 0.13.x , 0.14.x , 15.x.x . |
2 | 15 , 16 |
3 | 15 , 16 |
3.0.1 | ^16.3. |
4 | ^16.3 , 17 , 18 |
5 | 17 , 18 |
API
Share buttons
1import { 2 EmailShareButton, 3 FacebookShareButton, 4 GabShareButton, 5 HatenaShareButton, 6 InstapaperShareButton, 7 LineShareButton, 8 LinkedinShareButton, 9 LivejournalShareButton, 10 MailruShareButton, 11 OKShareButton, 12 PinterestShareButton, 13 PocketShareButton, 14 RedditShareButton, 15 TelegramShareButton, 16 TumblrShareButton, 17 TwitterShareButton, 18 ViberShareButton, 19 VKShareButton, 20 WhatsappShareButton, 21 WorkplaceShareButton, 22} from "react-share";
Share button props
Required props | Optional props | |
---|---|---|
All | children (string/element): React nodeurl (string): URL of the shared page | disabled (bool): Disables click action and adds "disabled" classdisabledStyle (object, default={ opacity: 0.6 } ): Disabled stylewindowWidth , windowHeight (number, different default for all share buttons): opened window dimensionsbeforeOnClick (() => Promise /() => void ): Takes a function that returns a Promise to be fulfilled before calling onClick . If you do not return promise, onClick is called immediately.openShareDialogOnClick (boolean): Open dialog on click. Defaults to true except on EmailShareButtononShareWindowClose (() => void ): Takes a function to be called after closing share dialog.resetButtonStyle (boolean, default=true ): Reset button element style. Preferred to be set to false if you want to customize the button style. |
EmailShareButton | - | subject (string): Title of the shared pagebody (string): Email, will be prepended to the url.separator (string, default=" " ): Separates body from the url |
FacebookShareButton | - | hashtag (string): A hashtag specified by the developer to be added to the shared content. People will still have the opportunity to remove this hashtag in the dialog. The hashtag should include the hash symbol. |
FacebookMessengerShareButton | appId (string): Facebook application id | redirectUri (string): The URL to redirect to after sharing (default: the shared url).to (string): A user ID of a recipient. Once the dialog comes up, the sender can specify additional people as recipients. |
HatenaShareButton | - | title (string): Title of the shared page |
InstapaperShareButton | - | title (string): Title of the shared pagedescription (string): Description of the shared page |
LinkedinShareButton | - | title (string): Title of the shared pagesummary (string): Description of the shared pagesource (string): Source of the content (e.g. your website or application name) |
LineShareButton | - | title (string): Title of the shared page |
LivejournalShareButton | - | title (string): Title of the shared pagedescription (string): Description of the shared page |
MailruShareButton | - | title (string): Title of the shared pagedescription (string): Description of the shared pageimageUrl (string): An absolute link to the image that will be shared |
OKShareButton | - | title (string): Title of the shared pagedescription (string): Description of the shared pageimage (string): An absolute link to the image that will be shared |
PinterestShareButton | media (string): An absolute link to the image that will be pinned | description (string): Description for the sharedpinId (string): Id of existing pin - If you’ve already pinned this page, use this to treat any new Pins of this page as repins of the original. Doing this can give you a better feel for engagement, because any Pins you create will count towards repins of your original Pin. |
PocketShareButton | - | title (string): Title of the shared page. Note that if Pocket detects a title tag on the page being saved, this parameter will be ignored and the title tag of the saved page will be used instead. |
RedditShareButton | - | title (string): Title of the shared page |
TelegramShareButton | - | title (string): Title of the shared page |
TumblrShareButton | - | title (string): Title of the shared pagetags : (Array<string> )caption (string): Description of the shared pageposttype (string, default=link ) |
TwitterShareButton | - | title (string): Title of the shared pageurl : (string)hashtags (array): Hashtagsrelated (array): Accounts to recommend following |
ViberShareButton | - | title (string): Title of the shared pageseparator (string), default=" " : Separates title from the url |
VKShareButton | - | title (string): Title of the shared pageimage (string): An absolute link to the image that will be sharednoParse (boolean): If true is passed, VK will not retrieve URL informationnoVkLinks (boolean): If true is passed, there will be no links to the user's profile in the open window. Only for mobile devices |
WeiboShareButton | - | title (string): Title of the shared pageimage (string): An absolute link to the image that will be shared |
WhatsappShareButton | - | title (string): Title of the shared pageseparator (string, default=" " ): Separates title from the url |
WorkplaceShareButton | - | quote (string): A quote to be shared along with the link.hashtag (string): A hashtag specified by the developer to be added to the shared content. People will still have the opportunity to remove this hashtag in the dialog. The hashtag should include the hash symbol. |
Share counts
1import { 2 FacebookShareCount, 3 HatenaShareCount, 4 OKShareCount, 5 PinterestShareCount, 6 RedditShareCount, 7 TumblrShareCount, 8 VKShareCount, 9} from "react-share";
All share count components take in only one mandatory prop: url
, which is the
URL you are sharing. className
prop is optional.
Example:
1<FacebookShareCount url={shareUrl} />
If you want to render anything else but the count,
you can provide a function as a child element that takes in shareCount
as an
argument and returns an element:
1<FacebookShareCount url={shareUrl}> 2 {(shareCount) => <span className="myShareCountWrapper">{shareCount}</span>} 3</FacebookShareCount>
Icons
1import { 2 EmailIcon, 3 FacebookIcon, 4 FacebookMessengerIcon, 5 GabIcon, 6 HatenaIcon, 7 InstapaperIcon, 8 LineIcon, 9 LinkedinIcon, 10 LivejournalIcon, 11 MailruIcon, 12 OKIcon, 13 PinterestIcon, 14 PocketIcon, 15 RedditIcon, 16 TelegramIcon, 17 TumblrIcon, 18 TwitterIcon, 19 ViberIcon, 20 VKIcon, 21 WeiboIcon, 22 WhatsappIcon, 23 WorkplaceIcon, 24 XIcon, 25} from "react-share";
Props:
-
size
: Icon size in pixels (number) -
round
: Whether to show round or rect icons (bool) -
borderRadius
: Allow rounded corners if using rect icons (number) -
bgStyle
: customize background style, e.g.fill
(object) -
iconFillColor
: customize icon fill color (string, default = 'white')
Example:
1<TwitterIcon size={32} round={true} />
About semantic versioning
This library uses the standard semver convention. However, the share buttons and and counts are prone to lots of changes that are not in control of this library. For example: if Facebook decides to change or deprecate it's API in a major way, this library will not get a major version bump just because of that. Keep this in mind when you are planning the maintenance of your application.
License
MIT
Icons
Icon paths provided by: react-social-icons.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
8 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
Reason
Found 2/17 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/nygardk/react-share/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/nygardk/react-share/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/nygardk/react-share/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/nygardk/react-share/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/nygardk/react-share/release.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More