Skip to main content

Sharing

In the previous tutorial on downloading we ended up with a path variable that has the location of the file that we downloaded.

We may want to share it, which allows another application to use it (for example emailing it). For this we'll use the @capacitor/share plugin.


_10
import { Share } from '@capacitor/share';
_10
...
_10
await Share.share(
_10
{
_10
title: 'Share PDF',
_10
text: 'Share the PDF',
_10
files: [path]
_10
}
_10
);

Here, we have taken the path variable that was set when we downloaded the file and called the share method which will show the native dialog to share a file.

You can try out the share feature in this sample repository.