Overview
Sovran supports deep linking through custom URL schemes to enable seamless token imports from other apps, websites, and QR codes. The app registers two URL schemes:cashu:// and sovran://.
Deep links are automatically processed when the app is opened from a URL, even if the app wasn’t running.
Supported Schemes
Sovran registers the following URL schemes:cashu://
Standard Cashu protocol scheme for ecash tokens:sovran://
Sovran-specific scheme for app-specific deep links:Implementation
Hook Setup
The deep link handler is implemented as a React hook:URL Structure
Deep links follow this structure:Processing Flow
1
URL Detection
Expo’s
Linking.useURL() hook detects when app is opened from URL2
Scheme Validation
Check if scheme matches
cashu:// or sovran://3
Route Exclusion
Skip router-handled URLs like
sovran://camera4
Token Extraction
Extract token data from URL hostname
5
Processing
Pass to
processPaymentString for validation and import6
Error Handling
Show user-friendly popup on failure
URL Parsing
Expo Linking parses URLs into structured data:Integration with Payment Processing
Deep links use the same payment string processor as QR codes and manual input:Platform Configuration
iOS
URL schemes are registered in Info.plist via app.json:CFBundleURLTypesin Info.plist- App can be opened from Safari, Messages, etc.
- Universal links support (optional)
Android
Intent filters are automatically configured:Error Handling
Errors during deep link processing show a user-friendly popup:- Invalid token format
- Unsupported token version
- Network error contacting mint
- User wallet not initialized
Testing Deep Links
iOS Simulator
Android Emulator
Physical Device
Create test QR codes or share links via Messages/WhatsApp.Router-Specific Links
Some URLs are handled by the router instead of payment processing:sovran://camera- Open camera screen- Future:
sovran://settings,sovran://backup, etc.
Security Considerations
Validation Steps
- Scheme Check: Only process
cashu://andsovran:// - Format Validation: Ensure token matches expected format
- User Confirmation: Show preview before importing large amounts
- Mint Verification: Check mint is trusted before accepting tokens
Best Practices
User Experience
User Experience
- Immediate Feedback: Show processing indicator when link opens app
- Clear Errors: Provide specific error messages for different failure modes
- Confirmation: Confirm import before adding tokens to wallet
- State Restoration: Handle links even when app is backgrounded
Error Recovery
Error Recovery
- Validation First: Validate token format before attempting import
- Network Handling: Gracefully handle offline/network errors
- User Guidance: Suggest actions when link processing fails
- Logging: Log errors for debugging without exposing sensitive data
Security
Security
- Input Validation: Never trust deep link data without validation
- Rate Limiting: Prevent abuse by limiting processing frequency
- User Awareness: Show source/amount before importing
- Safe Defaults: Default to safest option when uncertain
URL Generation
To create deep links for sharing tokens:Advanced Features
Query Parameters
Deep links can include query parameters for additional context:Universal Links (iOS)
For better UX, configure universal links (HTTPS URLs that open app):https://sovran.money/receive/token123 to open the app.
Code Reference
Source Files
hooks/useDeeplink.ts:1-47- Main deep link handlerapp.json:7- URL scheme registrationhooks/coco/useProcessPaymentString- Payment string processinghelper/popup.ts- Error popup utilities
Key Functions
useDeeplink()- Hook for handling deep linksLinking.useURL()- React hook for URL detectionLinking.parse(url)- Parse URL into componentsprocessPaymentString({ data, type })- Process token datadeeplinkFailedPopup({ text })- Show error to user