Plugin EcosystemData & Storage
Share
import { Callout } from 'fumadocs-ui/components/callout';
Triggers the native sharing dialogs to share content with other apps.
Overview
The Share API hooks into the native OS share sheets (UIActivityViewController on iOS, Intent.ACTION_SEND on Android) allowing users to seamlessly send text, URLs, or files from your app to external applications like messaging, email, or social media.
Enterprise React Example
In a document management app, you might want to share a generated report link.
import React, { useState } from 'react';
export default function ReportSharer({ reportUrl, reportTitle }: { reportUrl: string, reportTitle: string }) {
const [sharing, setSharing] = useState(false);
const shareReport = async () => {
setSharing(true);
try {
await window.easycord.share.shareText({
title: 'Q3 Financial Report',
text: `Please review the latest financial report: ${reportTitle}`,
url: reportUrl
});
} catch (err) {
console.error('Sharing failed or was cancelled by the user', err);
} finally {
setSharing(false);
}
};
return (
<div className="p-4 bg-gray-50 rounded shadow">
<h3 className="font-semibold text-lg">{reportTitle}</h3>
<button
onClick={shareReport}
disabled={sharing}
className="mt-2 bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 disabled:opacity-50"
>
{sharing ? 'Sharing...' : 'Share Report'}
</button>
</div>
);
}API Reference
shareText(options)
Opens the native share sheet with the provided text and URL.
Parameters:
options(Object):title(string, optional): A title for the shared content (primarily used by email subjects).text(string, optional): The body text to share.url(string, optional): A URL to append to the shared message.
Returns: Promise<void>
shareFile(options)
Shares a file located on the device's local file system.
Parameters:
options(Object):title(string, optional): Title for the share dialog.filePath(string): The absolute path to the local file (e.g. from thefsplugin).mimeType(string): The MIME type of the file (e.g.application/pdf).
Returns: Promise<void>