Skip to main content

@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).

ParamType
optionsShareOptions

Returns: Promise<void>

canShare()​

Whether the current platform supports sharing.

Returns: Promise<CanShareResult>

Interfaces​

ShareOptions​

PropTypeDescription
titlestringShare subject (used as the email subject etc. on some platforms; maps to ShareTextRequest.Subject).
textstringShare text.
urlstringShare link (can be provided together with text).
dialogTitlestringShare sheet title (Android chooser etc.; maps to ShareRequestBase.Title).

CanShareResult​

PropTypeDescription
canSharebooleanWhether the current platform supports sharing (all MAUI target platforms do, always true).