Skip to main content

Lovable Prompt

Add iOS home widget 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'Create a dynamic home widget system that uses Despia’s command method like: despia(`widget://${svg}?refresh=${refresh_time}`) to set and update SVG content in iOS home screen widgets with personalized user data.
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
The refresh time is set in minutes, for example, refresh_time = 1 means the widget content will refresh every minute using background processing, even when the app is closed.
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: Despia acts as a bridge between your Lovable app and iOS home widget system. Smart widgets are SVG-based widgets that display dynamic content from your backend, update automatically at specified intervals, and can show user-specific data. Every time the widget requests the image, it loads data from your backend and injects text using string replacement for tokenized text like {NAME} and {SCORE} with user data from the database.

Installation

Install the Despia package from NPM:

Usage

1. Import the SDK

2. Set Static Fallback Widget

Define your static SVG fallback widget URL:
Set the widget using Despia function call:

3. Set Dynamic Widget with User Data

Define your dynamic SVG widget URL with user ID:
Update widget after user login:

4. Update Widget Content

To refresh widget content with new data:

5. Backend Implementation

Your backend endpoint should return SVG content with proper headers:

6. Refresh Rate Options

Choose appropriate refresh intervals:

Backend Integration

Your backend endpoint should return SVG content with tokenized text replacement:

Resources

  • NPM Package
  • 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 native iOS smart widgets into your generated apps with dynamic SVG content and real-time data updates. For additional support or questions, please contact our support team at support@despia.com