DEV Community

Cover image for Share files on React Native
Gabriel Rufino
Gabriel Rufino

Posted on

Share files on React Native

File sharing is a very common feature in many apps. For this purpose on React Native, we can use the lib React Native Share.

Install React Native Share

$ npm install react-native-share --save
Enter fullscreen mode Exit fullscreen mode

One more step for iOS

$ npx pod-install
# or
$ cd ios && pod install
Enter fullscreen mode Exit fullscreen mode

Share a file

import React, {useCallback} from 'react';
import {View, Button} from 'react-native';
import Share from 'react-native-share';

export default function ShareAudio () {
  const onShareAudio = useCallback(function () {{
      url: `file:///data/data/com.yourapp/files/audio.mp3`,
      type: 'audio/mp3',
  }, []);

  return (
        title="Share audio"
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

kumard3 profile image
Kumar Deepanshu

so i have a Question , I am planning to build an file transfer app , which share files between applications , and save it to the local file system , just like Share It ,
so can i use react-native-share for that purpose .

rajajaganathan profile image
Raja Jaganathan • Edited

Thanks for writing up!

gabrielrufino profile image
Gabriel Rufino

Thank you for your feedback :D

aftabaminzoobiapps profile image

How to share a video. can you help me please.