npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-share-with-hatena

v1.16.1

Published

Easy social media share buttons and share counts.

Downloads

1

Readme

react-share

npm version Download Count

Easy social media share buttons and share counts.

Features

  • no external script loading, i.e. no dependencies on SDKs
  • opens a popup share-window
  • share buttons for:
    • Facebook
    • Twitter
    • Telegram
    • Google+
    • Whatsapp
    • LinkedIn
    • Pinterest
    • VK
    • Odnoklassniki
    • Reddit
    • email
  • share counts for
    • Facebook
    • Google+
    • Linkedin
    • Pinterest
    • VK
    • Odnoklassniki
    • Reddit
  • social media icons included in the library
  • supports also custom icons

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,
  OKShareButton,
  RedditShareButton,
  EmailShareButton,
} = ShareButtons;
Share button props

| |Required props|Optional props| |-------|--------|--------------| |All|children: 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. If you do not return promise, onClick is called immediately.onShareWindowClose: Takes a function to be called after closing share dialog.| |FacebookShareButton|-|quote: A quote to be shared along with the link. (string)hashtag: 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. (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)| |PinterestShareButton|media: 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)| |OKShareButton|-|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)| |RedditShareButton|-|title: Title of the shared page (string)| |EmailShareButton|-|subject: Title of the shared page (string)body: Body of the email (string), defaults to shared url.|

Share counts

const {
  FacebookShareCount,
  GooglePlusShareCount,
  LinkedinShareCount,
  PinterestShareCount,
  VKShareCount,
  OKShareCount,
  RedditShareCount,
} = 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');
const OKIcon = generateShareIcon('ok');
const RedditIcon = generateShareIcon('reddit');
const EmailIcon = generateShareIcon('email');

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} />

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.