Skip to main content

Lovable Prompt

Add identity vault 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'Store identity data by calling:
Retrieve identity data by calling:
The identity vault provides:
  • Persistent storage - Data survives app restarts, updates, and even uninstall/reinstall
  • Cross-device sync - Works across all user’s devices with the same Apple ID or Google account
  • User tracking - Identify the same user even after they uninstall and reinstall your app
  • Face ID protection - Optional biometric lock for sensitive actions
  • Automatic timeout - 30-second timeout prevents app freezing
Parameters:
  • key - Name for your stored data (use simple names like “userId”, “deviceId”, “sessionToken”)
  • value - The data to store (text/string)
  • locked - Set to 'true' to require Face ID/fingerprint, 'false' for normal storage
Perfect for:
  • Identifying users across sessions
  • Preventing free trial abuse (track device even after uninstall)
  • Storing login session tokens
  • Protecting sensitive actions with Face ID/Touch ID
  • Saving user preferences and app settings
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

The Identity Vault uses your phone’s built-in secure storage:
  • iPhone: Uses iCloud Key Value Store - data syncs automatically across all devices with the same Apple ID
  • Android: Uses Key/Value Backup API - data backs up to Google Drive and restores when app is reinstalled
Both systems are built into the operating system and handle encryption automatically. Your data is protected and syncs across devices with the same account. When locked is set to true, users must authenticate with Face ID (iPhone), Touch ID (iPhone), or fingerprint (Android) to access the data. Why this matters: Even if someone uninstalls your app and reinstalls it, the vault data comes back. This helps you identify returning users and prevent abuse of free trials.

Installation

Install the Despia package from NPM:

Usage

1. Import the SDK

2. Store Data

Basic storage:
Protected with Face ID/fingerprint:

3. Retrieve Data

Read basic data:
Read Face ID protected data:

4. Prevent Free Trial Abuse

5. Simple Login Session

6. Protect Sensitive Actions with Face ID

7. Track App Opens

8. Handle Errors

9. Common Examples

Remember device:
Save user settings:
Protect with Face ID:
Check first app launch:

What to Store

Good Uses

  • User IDs and device IDs
  • Free trial tracking
  • Login session tokens
  • App preferences and settings
  • First-time user flags
  • Actions that need Face ID confirmation

Don’t Store

  • Passwords (use proper login systems)
  • Credit card numbers (use payment processors)
  • Private encryption keys
  • Data that requires legal compliance (medical, financial records)

Tips

  1. Keep it simple - Store simple text values like IDs and tokens
  2. Use Face ID for important actions - Set locked=true when you want user confirmation
  3. Data persists forever - It survives uninstall/reinstall, perfect for tracking users
  4. Works offline - No internet connection needed
  5. Syncs across devices - Same data on user’s iPhone and iPad (iCloud) or Android devices (Google account)

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 purchase restoration into your generated apps. For additional support or questions, please contact our support team at support@despia.com