Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-mobile-share

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share).

  • 2.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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:

FieldTypeDescription
titlestringRequired. Must have a title.
textstringOptional. Add a description.
urlstringOptional. Any valid url.
imagesarrayOptional. 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

Keywords

FAQs

Package last updated on 27 Sep 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc