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

react-native-share

Package Overview
Dependencies
Maintainers
5
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-share

Social share, sending simple data to other apps.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
259K
decreased by-5.07%
Maintainers
5
Weekly downloads
 
Created

What is react-native-share?

The react-native-share package allows you to share content such as text, images, and files from your React Native app to other apps on the user's device. It supports both Android and iOS platforms.

What are react-native-share's main functionalities?

Share Text

This feature allows you to share plain text messages. The code sample demonstrates how to share a simple text message using the react-native-share package.

import Share from 'react-native-share';

const shareText = async () => {
  const shareOptions = {
    message: 'Hello, this is a text message!',
  };
  try {
    await Share.open(shareOptions);
  } catch (error) {
    console.log('Error =>', error);
  }
};

Share Image

This feature allows you to share images. The code sample demonstrates how to share an image using a base64 encoded string.

import Share from 'react-native-share';

const shareImage = async () => {
  const shareOptions = {
    url: 'data:image/png;base64,<base64_encoded_image>',
  };
  try {
    await Share.open(shareOptions);
  } catch (error) {
    console.log('Error =>', error);
  }
};

Share File

This feature allows you to share files. The code sample demonstrates how to share a file from a given file path.

import Share from 'react-native-share';

const shareFile = async () => {
  const shareOptions = {
    url: 'file://path/to/your/file.pdf',
  };
  try {
    await Share.open(shareOptions);
  } catch (error) {
    console.log('Error =>', error);
  }
};

Share with Social Media

This feature allows you to share content directly to specific social media apps. The code sample demonstrates how to share a message directly to WhatsApp.

import Share from 'react-native-share';

const shareToWhatsApp = async () => {
  const shareOptions = {
    message: 'Hello, sharing this via WhatsApp!',
    social: Share.Social.WHATSAPP,
  };
  try {
    await Share.shareSingle(shareOptions);
  } catch (error) {
    console.log('Error =>', error);
  }
};

Other packages similar to react-native-share

Keywords

FAQs

Package last updated on 22 Jul 2019

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