Catalog npm
Back to packageRELEASE DETAILS

4.4.1

npm

@0xcj/react-share

Social media share buttons and share counts for React.

buttoncomponentcountmediareactreact-componentsharesocialsocial-media
Published18 Sept 2023
Direct dependencies34
Transitive dependenciesNot calculated

README

Current package documentation

react-share

npm version Download Count

Social media share buttons and share counts for React.

Share buttons and counts example

Migrating from v2 to v3? Read changelog.

Migrating from v1 to v2? Read migration notes.

Features

  • no external script loading, i.e. no dependencies on SDKs
  • opens a popup share-window
  • share buttons for:
    • Facebook
    • Facebook Messenger
    • Twitter
    • Telegram
    • Whatsapp
    • LinkedIn
    • Pinterest
    • VK
    • Odnoklassniki
    • Reddit
    • Tumblr
    • Mail.Ru
    • LiveJournal
    • Viber
    • Workplace
    • Line
    • Weibo
    • Pocket
    • Instapaper
    • Hatena
    • email
  • share counts for
    • Facebook
    • Pinterest
    • VK
    • Odnoklassniki
    • Reddit
    • Tumblr
    • Hatena
  • social media icons included in the library
  • supports also custom icons

Demo

View demo

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

Install

npm install react-share --save

Compatibility

Version 1.x.x: compatible with React versions 0.13.x, 0.14.x and 15.x.x.

Version 2.x.x: compatiblity is tested with React 15 and 16.

Version 3.x.x: compatiblity is tested with React 15 and 16.

Version 3.0.1: compatible with React ^16.3.

Version 4.x.x: compatible with React >=16.3.

API

Share buttons

import {
  EmailShareButton,
  FacebookShareButton,
  HatenaShareButton,
  InstapaperShareButton,
  LineShareButton,
  LinkedinShareButton,
  LivejournalShareButton,
  MailruShareButton,
  OKShareButton,
  PinterestShareButton,
  PocketShareButton,
  RedditShareButton,
  TelegramShareButton,
  TumblrShareButton,
  TwitterShareButton,
  ViberShareButton,
  VKShareButton,
  WhatsappShareButton,
  WorkplaceShareButton
} from "react-share";
Share button props
Required propsOptional props
Allchildren (string/element): React node
url (string): URL of the shared page
disabled (bool): Disables click action and adds "disabled" class
disabledStyle (object, default={ opacity: 0.6 }): Disabled style
windowWidth, windowHeight (number, different default for all share buttons): opened window dimensions
beforeOnClick (() => 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 EmailShareButton
onShareWindowClose (() => 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 page
body (string): Email, will be prepended to the url.
separator (string, default=" "): Separates body from the url
FacebookShareButton-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.
FacebookMessengerShareButtonappId (string): Facebook application idredirectUri (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 page
description (string): Description of the shared page
LinkedinShareButton-title (string): Title of the shared page
summary (string): Description of the shared page
source (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 page
description (string): Description of the shared page
MailruShareButton-title (string): Title of the shared page
description (string): Description of the shared page
imageUrl (string): An absolute link to the image that will be shared
OKShareButton-title (string): Title of the shared page
description (string): Description of the shared page
image (string): An absolute link to the image that will be shared
PinterestShareButtonmedia (string): An absolute link to the image that will be pinneddescription (string): Description for the shared media.
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 page
tags: (Array<string>)
caption (string): Description of the shared page
posttype (string, default=link)
TwitterShareButton-title (string): Title of the shared page
via: (string)
hashtags (array): Hashtags
related (array): Accounts to recommend following
ViberShareButton-title (string): Title of the shared page
separator (string), default=" ": Separates title from the url
VKShareButton-title (string): Title of the shared page
image (string): An absolute link to the image that will be shared
noParse (boolean): If true is passed, VK will not retrieve URL information
noVkLinks (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 page
image (string): An absolute link to the image that will be shared
WhatsappShareButton-title (string): Title of the shared page
separator (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

import {
  FacebookShareCount,
  HatenaShareCount,
  OKShareCount,
  PinterestShareCount,
  RedditShareCount,
  TumblrShareCount,
  VKShareCount
} 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:

<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

import {
  EmailIcon,
  FacebookIcon,
  FacebookMessengerIcon,
  HatenaIcon,
  InstapaperIcon,
  LineIcon,
  LinkedinIcon,
  LivejournalIcon,
  MailruIcon,
  OKIcon,
  PinterestIcon,
  PocketIcon,
  RedditIcon,
  TelegramIcon,
  TumblrIcon,
  TwitterIcon,
  ViberIcon,
  VKIcon,
  WeiboIcon,
  WhatsappIcon,
  WorkplaceIcon
} 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:

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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 35

Native requirements
34 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
classnames
Environment
{
  "local_name": "classnames",
  "alias": false,
  "peer_metadata": null
}
^2.3.2runtime
jsonp
Environment
{
  "local_name": "jsonp",
  "alias": false,
  "peer_metadata": null
}
^0.2.1runtime
@types/assert
Environment
{
  "local_name": "@types/assert",
  "alias": false,
  "peer_metadata": null
}
1.5.6development
@types/jsonp
Environment
{
  "local_name": "@types/jsonp",
  "alias": false,
  "peer_metadata": null
}
0.2.1development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^16.9.49development
@types/react-dom
Environment
{
  "local_name": "@types/react-dom",
  "alias": false,
  "peer_metadata": null
}
^16.9.8development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^5.40.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^5.40.0development
cross-env
Environment
{
  "local_name": "cross-env",
  "alias": false,
  "peer_metadata": null
}
7.0.3development
css-loader
Environment
{
  "local_name": "css-loader",
  "alias": false,
  "peer_metadata": null
}
6.7.1development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
8.25.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^8.5.0development
eslint-plugin-babel
Environment
{
  "local_name": "eslint-plugin-babel",
  "alias": false,
  "peer_metadata": null
}
^5.3.1development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
2.26.0development
eslint-plugin-jsx-a11y
Environment
{
  "local_name": "eslint-plugin-jsx-a11y",
  "alias": false,
  "peer_metadata": null
}
6.6.1development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^4.2.1development
eslint-plugin-react
Environment
{
  "local_name": "eslint-plugin-react",
  "alias": false,
  "peer_metadata": null
}
7.31.10development
eslint-plugin-react-hooks
Environment
{
  "local_name": "eslint-plugin-react-hooks",
  "alias": false,
  "peer_metadata": null
}
4.6.0development
eslint-webpack-plugin
Environment
{
  "local_name": "eslint-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
^3.2.0development
file-loader
Environment
{
  "local_name": "file-loader",
  "alias": false,
  "peer_metadata": null
}
6.2.0development
html-webpack-plugin
Environment
{
  "local_name": "html-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
5.5.0development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
2.7.1development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
16.8.0development
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
16.8.0development
react-hot-loader
Environment
{
  "local_name": "react-hot-loader",
  "alias": false,
  "peer_metadata": null
}
4.13.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^3.0.2development
style-loader
Environment
{
  "local_name": "style-loader",
  "alias": false,
  "peer_metadata": null
}
3.3.1development
terser-webpack-plugin
Environment
{
  "local_name": "terser-webpack-plugin",
  "alias": false,
  "peer_metadata": null
}
5.3.6development
ts-loader
Environment
{
  "local_name": "ts-loader",
  "alias": false,
  "peer_metadata": null
}
9.4.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
4.8.4development
url-loader
Environment
{
  "local_name": "url-loader",
  "alias": false,
  "peer_metadata": null
}
4.1.1development
webpack
Environment
{
  "local_name": "webpack",
  "alias": false,
  "peer_metadata": null
}
5.74.0development
webpack-cli
Environment
{
  "local_name": "webpack-cli",
  "alias": false,
  "peer_metadata": null
}
4.10.0development
webpack-dev-server
Environment
{
  "local_name": "webpack-dev-server",
  "alias": false,
  "peer_metadata": null
}
4.11.1development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^16.3.0 || ^17 || ^18peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-vuL3m1VA1cYf3R3OmTFsjat9gRcwb/dyoi06vQhA7mkmJ2evRWDBf6POnWtTFjCjf1IoH/BjmYVjCU2kAU2G+Q==",
  "shasum": "83ea1776424319bfeb93fcb136170e4d86293fd1",
  "tarball": "https://registry.npmjs.org/@0xcj/react-share/-/react-share-4.4.1.tgz",
  "fileCount": 227,
  "unpackedSize": 249868,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIAEDVsETdn+qdwnT3Jn/fUK4cVnj8O2UbamSRuqfUBhfAiEAolu/m/BQPJZQSx4eDhMxQM8kLd9TbnmHrIjBa93A9uk="
    }
  ]
}

Repository

PENDING
nygardk/react-share

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:02 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:9b79aa833edfdd6d0602e9590e85f52fcaeac0bf274c2fd35c696344f1b6569d

Other collected versions

4.4.219 SeptView all collected versions →