Skip to main content

Lovable Prompt

Add shared data receiving functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: npm install despia-nativeThen import it: import despia from 'despia-native'Register a global callback function window.onSharedDataReceived = function(value, type) that receives shared content when users share images, URLs, text, or files such as PDFs to your app. The type parameter will be 'image', 'url', 'text', or 'file', and the value parameter contains the shared content. For 'file', a third parameter meta contains { name, mimeType, size }.
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
How it works: When users share content (like a photo from their gallery or a link from their browser) to your app, the Despia runtime opens your application in a web view and calls the onSharedDataReceived(value, type) function with the shared data. Images are provided as data URLs, URLs as plain strings, and text as plain strings. Files (PDFs, documents, audio, video, archives) are provided as a URL to the file, which you read with fetch(value), with type 'file', and the third argument meta gives the file’s name, MIME type and size. One item is shared at a time.
Sharing files (PDFs, documents, audio, video, archives) into your app, the file type, works on iOS and Android builds made on or after October 31, 2026. Older builds only receive image, url and text. Rebuild your app in the Despia Editor to get it.

Installation

Install the Despia package from NPM:

Usage

1. Import the SDK

2. Register the Callback

Register the onSharedDataReceived callback to handle shared data:

Example Use Cases

Handling a shared image:
Handling a shared URL:
Handling shared text:
Handling a shared file, such as a PDF:

Supported Content Types

  • Images: Provided as data URLs (e.g., data:image/png;base64,...) with type 'image'
  • URLs: Provided as URL strings (e.g., https://example.com) with type 'url'
  • Text: Provided as plain text strings with type 'text'
  • Files: PDFs, documents, audio, video and archives, provided as a URL to the file (read it with fetch(value)) with type 'file' and meta = { name, mimeType, size }. Requires a build made on or after October 31, 2026.
  • Videos: Not yet supported

Resources

View full NPM documentation for additional configuration options

Lovable Integration

This SDK is optimized for Lovable’s prompt-based AI builder, enabling quick integration of shared content handling into your generated apps. For additional support or questions, please contact our support team at support@despia.com