2.2.3 • Published 10 months ago

react-mobile-share v2.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

React-Mobile-Share

Provides an easy and simple way to share data (such as text, url and media) via mobile’s built-in share module. It is based on Web Share API.

This works only with secure contexts (HTTPS).

💡 Features

  • Lightweight
  • Share text, url and images
  • Works on Android and iOS

🔧 Installation

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

🖥️ Demo

Try with CodeSandbox

📱 Preview

Android    iOS

📦 Usage

import { shareOnMobile } from "react-mobile-share";

const imgBase64 = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2...";

const App = () => {
  return (
    <div>
      <button
        onClick={() =>
          shareOnMobile({
            text: "Hey checkout our package react-mobile-share",
            url: "https://www.npmjs.com/package/react-mobile-share",
            title: "React-Mobile-Share",
            images: [imgBase64],
          })
        }
      >
        Share
      </button>
    </div>
  );
};

export default App;

👀 API References

Functions

  shareOnMobile(data, fallbackFn)

Takes the following parameters:

ParameterTypeDescription
dataobjectRequired
fallbackFnfunctionOptions: return a message

Data Object (1st Parameter)

{
    text: "Hey checkout our package react-mobile-share",
    url: "https://www.npmjs.com/package/react-mobile-share",
    title: "React-Mobile-Share",
    images: [imgBase64],
}

Object must contain the following fields: | Field | Type | Description | | :-------- | :------- | :-------------------------------- | | title | string | Required. Must have a title.| | text | string | Optional. Add a description. | | url | string | Optional. Any valid url. | | images | array | Optional. Should be a valid array of base64 strings. |

Fallback Function (2nd Parameter)

function(message) {
    console.log("fallback", message)
}

This will invoked when any failure occurs.

📜 License

MIT

🤝🏼 Contributions

We welcome pull requests! Explore open issues to find opportunities to contribute or open a new issue to share your ideas or report bugs—your help improves this library

Contribution Guidelines

2.2.3

10 months ago

2.2.1

12 months ago

2.2.0

12 months ago

2.2.2

12 months ago

2.1.0

12 months ago

2.0.0

1 year ago

1.0.31

2 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.30

3 years ago

1.0.16

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.27

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.0

3 years ago