JSPM

react-web-social-share

2.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25137F
  • License MIT

Web Social Share API Wrapper with fallback for unsupported browsers

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-web-social-share) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    react-web-share

    Tiny Web Share API wrapper with fallback for unsupported browsers

    GitHub Actions Status NPM gzip

    Edit react-web-share

    💡 most browsers restricts web share api only to https websites

    ✨ Features

    • 🍃 Only ~6kb gzipped and no external dependencies
    • 🌀 Uses React Portal
    • ✌ Written w/ TypeScript

    🔧 Installation

    npm i react-web-share    # npm
    yarn add react-web-share # yarn

    Preview

    Mobile

    Mobile Preview

    Desktop

    Desktop Preview

    📦 Example

    import React, { useState } from "react";
    import { RWebShare } from "react-web-share";
    
    const Example = () => {
      return (
        <div>
          <RWebShare
            data={{
              text: "Like humans, flamingos make friends for life",
              url: "https://on.natgeo.com/2zHaNup",
              title: "Flamingos",
            }}
            onClick={() => console.log("shared successfully!")}
          >
            <button>Share 🔗</button>
          </RWebShare>
        </div>
      );
    };
    
    export default Example;

    👀 Props

    Prop Description Type Default
    data Share Object {text, url, title} {text: "", url: currentURL, title: "Share"}
    sites sites string[] all platforms (see list below for key list)
    closeText translate close string localise close text
    onClick callback on sucessful share
    disableNative disables native share boolean false

    🌎 Sites

    • facebook
    • twitter
    • whatsapp
    • reddit
    • telegram
    • linkedin
    • mail
    • copy (Copy to Clipboard)
    • vk
    • okru

    📜 License

    MIT © devgupta