Share

Share: The Native Share Sheet

Share opens the system share sheet with text, a URL or files. Its promise settles only when the sheet closes, and dismissing the sheet rejects it:

Sharing a book in src/js/lab.jsJavaScript
export async function share() {
  const { value } = await Share.canShare();
  try {
    const { activityType } = await Share.share({
      title: 'Salt and Saffron', text: 'Found this on BookNest:',
      url: 'https://example.com/books/3', dialogTitle: 'Share this book',
    });
    return show('share', { canShare: value, activityType });
  } catch (err) {
    return show('share', { canShare: value, error: err.message });
  }
}

Pressing Back on the sheet:

Output of 54
LAB share {"canShare":true,"error":"Share canceled"}
A local notification with its two actions, the Android share sheet, and a Chrome Custom Tab opened by Browser
A local notification with its two actions, the Android share sheet, and a Chrome 1 Custom Tab opened by Browser

Android joined text and url into one string, "Found this on BookNest: https://example.com/books/3", and the Android 16 sheet did not show dialogTitle, an Android-only option, at all. When the reader does pick an app, activityType identifies it, though the plugin's own documentation warns it can be an empty string. To share an image, save it with Filesystem first and pass its file:// URI in files. In a browser the plugin calls the Web Share API, and canShare() returns false where navigator.share is missing.