Lovable Prompt
Add local storage functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Create a local storage system that uses Despia URLs like: Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'This SDK is compatible only with the Native Despia Runtime. Ensure that the User Agent string includes “despia” before running this code. If the User Agent string doesn’t include “despia” you can use Local Storage as a web fallback.
despia("writevalue://{YOUR-JSON-STRING-DATA}") to save data and const data = await despia("readvalue://", ["storedValues"]) to retrieve data. The data is stored as a single string on the device and returned in the response object.You can access the data like this:Refrain from blocking any UI elements or adding loading screens before data is loaded. This is because most sessions will not have initial data yet if no data has been stored.
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Write Data
Save data to device storage:3. Read Data
Retrieve stored data:Storage Details
- Single key-value pair: One storage slot per app
- String format: Data must be URL-encoded strings (use JSON for objects)
- Promise-based: Use
awaitto retrieve data asynchronously - Property access: Request
["storedValues"]to get stored data
Resources
- NPM Package
- View full NPM documentation for additional configuration options