@napacitor/share
System share plugin (corresponds to @capacitor/share).
Installation
To use npm:
npm install @napacitor/share
To use yarn:
yarn add @napacitor/share
Sync native files:
npx nap sync
Usage
import { Share } from '@napacitor/share';
await Share.share({
title: 'Napacitor',
text: 'Check out this project',
url: 'https://example.com',
dialogTitle: 'Share to',
});
const { canShare } = await Share.canShare();
How It Works
Wraps the APIs described in the .NET MAUI Share documentation: Share.Default.RequestAsync(ShareTextRequest), where title → Subject, dialogTitle → Title, and text/url → Text/Uri. All MAUI target platforms support sharing, so canShare() always returns true.
Permissions
Android
No additional configuration required.
iOS
No additional configuration required.
Windows
No additional configuration required.
API
share(options)
Shows the system share sheet (throws INVALID_ARGUMENTS when neither text nor url is provided).
| Param | Type |
|---|---|
options | ShareOptions |
Returns: Promise<void>
canShare()
Whether the current platform supports sharing.
Returns: Promise<CanShareResult>
Interfaces
ShareOptions
| Prop | Type | Description |
|---|---|---|
title | string | Share subject (used as the email subject etc. on some platforms; maps to ShareTextRequest.Subject). |
text | string | Share text. |
url | string | Share link (can be provided together with text). |
dialogTitle | string | Share sheet title (Android chooser etc.; maps to ShareRequestBase.Title). |
CanShareResult
| Prop | Type | Description |
|---|---|---|
canShare | boolean | Whether the current platform supports sharing (all MAUI target platforms do, always true). |