Skip to main content
Back to plugins
@capgo/capacitor-share-target
Tutorial
@capgo/capacitor-share-target

Share Target

Receive shared content from other apps - text, images, and files

Guide

Tutorial on Share Target

Using @capgo/capacitor-share-target

Capacitor Share Target Plugin interface.

Install

bun add @capgo/capacitor-share-target
bunx cap sync

What This Plugin Exposes

  • addListener - Listen for shareReceived event.
  • removeAllListeners - Remove all listeners for this plugin.
  • getPluginVersion - Get the native Capacitor plugin version.

Example Usage

addListener

Listen for shareReceived event.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';

const listener = await CapacitorShareTarget.addListener('shareReceived', (event) => {
  console.log('Title:', event.title);
  console.log('Texts:', event.texts);
  event.files?.forEach(file => {
    console.log(`File: ${file.name} (${file.mimeType})`);
  });
});

// To remove the listener:
await listener.remove();

removeAllListeners

Remove all listeners for this plugin.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';

await CapacitorShareTarget.removeAllListeners();

getPluginVersion

Get the native Capacitor plugin version.

import { CapacitorShareTarget } from '@capgo/capacitor-share-target';

const { version} = await CapacitorShareTarget.getPluginVersion();
console.log('Plugin version:', version);

Full Reference

Keep going from Using @capgo/capacitor-share-target

If you are using Using @capgo/capacitor-share-target to plan native plugin work, connect it with @capgo/capacitor-share-target for the implementation detail in @capgo/capacitor-share-target, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.