Socket
Socket
Sign inDemoInstall

react-share

Package Overview
Dependencies
26
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-share

Easy social media share buttons and share counts.


Version published
Weekly downloads
414K
increased by5.78%
Maintainers
1
Install size
2.36 MB
Created
Weekly downloads
 

Changelog

Source

1.12.1 (Feb 25, 2017)

  • Replaced https://facebook.com/sharer.php with https://www.facebook.com/sharer/sharer.php

Readme

Source

react-share

npm version Download Count

Easy social media share buttons and share counts.

Share buttons and counts example

Features

  • no external script loading, i.e. no dependencies on SDKs
  • opens a popup share-window
  • sharing buttons for Facebook, Twitter, Google+, LinkedIn, Pinterest, VK
  • share counts for Facebook, Google+, Linkedin and Pinterest
  • share buttons with generated icons or custom icons of your choice
Demo

To run demos: clone repo and run npm install && npm run run-demos and open http://localhost:8080/demo0/.

Install

npm install react-share --save

Browser

ShareButtons work on all browsers.

ShareCounts works on all browsers, with the exception of Goolge Plus share count working only on IE11 and newer (XHR CORS problem).

Compatibility

Compatible with React versions 0.13.x, 0.14.x and 15.x.x.

API

import {
  ShareButtons,
  ShareCounts,
  generateShareIcon
} from 'react-share';

Share buttons

const {
  FacebookShareButton,
  GooglePlusShareButton,
  LinkedinShareButton,
  TwitterShareButton,
  TelegramShareButton,
  WhatsappShareButton,
  PinterestShareButton,
  VKShareButton
} = ShareButtons;
Share button props
Required propsOptional props
Allchildren: A React node (e.g. string or element)
url: URL of the shared page (string)
disabled: Disables click action and adds disabled class (bool)
disabledStyle: Style when button is disabled (object, default = { opacity: 0.6 })
windowWidth, windowHeight: opened window dimensions (int, different defaults for all share buttons)
beforeOnClick: Takes a function that returns a Promise to be fulfilled before calling onClick
FacebookShareButton-title: Title of the shared page (string)
description: Description of the shared page (string)
picture: An absolute link to the image that will be shared (string)
GooglePlusShareButton--
LinkedinShareButton-title: Title of the shared page (string)
description: Description of the shared page (string)
TwitterShareButton-title: Title of the shared page (string)
via: (string)
hashtags: (array)
TelegramShareButton-title: Title of the shared page (string)
WhatsappShareButton-title: Title of the shared page (string)
separator: Separates title from the url, default: " " (string)
PinterestShareButtonmedia: An absolute link to the image that will be pinned (string)description: Description for the shared media.
VKShareButton-title: Title of the shared page (string)
description: Description of the shared page (string)
image: An absolute link to the image that will be shared (string)
Notes

Whatsapp share button uses whatsapp protocol in shared links (whatsapp://send). Thus, it is meant to be used on mobile views and will not work on (all) desktop web browsers.

Share counts

const {
  FacebookShareCount,
  GooglePlusShareCount,
  LinkedinShareCount,
  PinterestShareCount,
  VKShareCount
} = ShareCounts;

All share count components take in only one mandatory prop: url, which is the URL you are sharing. className prop is optional.

Example:

<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:

<FacebookShareCount url={shareUrl}>
  {shareCount => (
    <span className="myShareCountWrapper">{shareCount}</span>
  )}
</FacebookShareCount>

Icons

const FacebookIcon = generateShareIcon('facebook');
const TwitterIcon = generateShareIcon('twitter');
const TelegramIcon = generateShareIcon('telegram');
const WhatsappIcon = generateShareIcon('whatsapp');
const GooglePlusIcon = generateShareIcon('google');
const LinkedinIcon = generateShareIcon('linkedin');
const PinterestIcon = generateShareIcon('pinterest');
const VKIcon = generateShareIcon('vk');

Props:

  • size: Icon size in pixels (number)

  • round: Whether to show round or rect icons (bool)

  • iconBgStyle: customize background style, e.g. fill (object)

  • logoFillColor: customize logo's fill color (string, default = 'white')

Example:

<TwitterIcon size={32} round={true} />

License

MIT

Icons

Icon paths provided by: react-social-icons.

Keywords

FAQs

Last updated on 25 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc