The video uses a specific AI coding tool to demonstrate the setup, but the configuration works 1:1 with Cursor, Claude Code, or any other tool. Despia is web framework and tooling agnostic, so the only thing that matters is defining the global
onSharedDataReceived callback before the runtime tries to invoke it.window.onSharedDataReceived(value, type) with the shared payload. Three content types are supported: image (as a data URL), url (as a string), and text (as a string). Video is not currently supported.
This is the opposite direction from Share Dialog and File Sharing, which both send content out of your app. Share Extension receives content sent in from other apps.
Apple Developer and Despia setup
Share Extension on iOS runs as a separate App Extension target with its own bundle identifier. The extension and your core app communicate through an App Group, which is the iOS sandbox-shared storage mechanism that lets two bundles read and write the same files. You configure the bundle ID and App Group in Apple Developer, then enable the target in the Despia Editor and rebuild.Sign in to Apple Developer
Go to developer.apple.com and sign in with the Apple Developer account that owns your app’s primary bundle ID. Navigate to Certificates, Identifiers & Profiles > Identifiers.
Create the App Group
Click the + button next to Identifiers, choose App Groups, and click Continue. Use a description like
MyApp Share Target and the identifier group.com.despia.myapp.sharetarget. Click Continue, then Register. The sharetarget suffix is the official Despia naming, do not invent your own.Add the App Group to your core app bundle ID
Back in Identifiers, find your core app (e.g.
com.despia.myapp), click into it, and check App Groups. Click Edit, select the group.com.despia.myapp.sharetarget group you just created, then Continue and Save. This links your core app to the shared storage.Create the Share Extension bundle ID
Click + under Identifiers again, choose App IDs, then App. Use a description like
MyApp Share Extension and the bundle ID com.despia.myapp.ShareExtensionTarget (your core bundle ID with .ShareExtensionTarget appended). This exact naming is what Despia provisions during the build, do not change it.Add the App Group to the Share Extension bundle ID
Scroll down to Capabilities, check App Groups, click Edit, and select the same
group.com.despia.myapp.sharetarget group. Click Continue and Save. Both bundles now share the same group, which is how the extension passes data to your core app.Enable Share Extension in the Despia Editor
Open the Despia Editor and go to App > Targets > Share into App. Toggle the integration on, then paste in:
- Share Extension Bundle ID:
com.despia.myapp.ShareExtensionTarget - App Group ID:
group.com.despia.myapp.sharetarget
Rebuild your app
Trigger a fresh build from the Despia Editor. The extension target has to be compiled into your app binary and signed with the matching provisioning profile, so this cannot be applied over-the-air. After the build finishes, your app appears in the system share sheet whenever a user shares an image, URL, or text from another app.
Installation
- Bundle
- CDN
How it works
Definewindow.onSharedDataReceived as a global function before the runtime needs to invoke it. The runtime calls this function with two arguments: the shared value and a string indicating the type ('image', 'url', or 'text').
window directly.
The three content types
| Type | Value shape | Common sources |
|---|---|---|
image | Data URL, e.g. data:image/jpeg;base64,/9j/4AAQ... | Photos app, Camera Roll, image previews from other apps |
url | URL string, e.g. https://example.com/article | Safari, Chrome, social apps sharing a link |
text | Plain text string | Notes, Messages, any app sharing selected text |
<img src> without going through any decoding step. To send the bytes to your backend, convert the data URL to a Blob first and post it as multipart form data, since most servers reject base64-in-JSON for large files.
Define the callback before the runtime invokes it
The order of operations matters. The runtime invokesonSharedDataReceived very early, sometimes before your React app has even mounted, so the callback has to be defined as soon as possible. The simplest pattern is to attach it once at the top level of your entry point.
Save a shared image to your backend
Convert the data URL to a Blob and upload it as multipart form data. Most storage backends reject base64-encoded JSON for large files, so the Blob path is what scales.Resources
NPM Package
despia-native