For a complete working example, see the React Native example app with chat UI, media gallery, and custom tool UIs.
Storage Adapters
The React Native SDK requires a storage adapter for persisting data like session state, authentication tokens, and preferences.AsyncStorage Adapter
The most common storage solution using@react-native-async-storage/async-storage:
Custom Storage Adapter
Implement your own storage adapter for alternative storage solutions:Secure Storage with Keychain
For sensitive data like API keys:Storage Keys
The SDK uses these predefined storage keys:Accessing Storage in Components
Use theuseStorage hook to access the storage adapter:
App State Handling
React Native apps transition between foreground and background states. The Jade SDK handles these transitions automatically.Default Behavior
By default, the SDK:- Pauses streaming when the app goes to background
- Maintains connection state for reconnection
- Resumes automatically when the app returns to foreground
useAppState Hook
Monitor app state in your components:App State Values
Conditional UI
Show different UI based on app state:Disable Background Pause
For apps that need to continue streaming in the background:Manual Reconnection
Handle reconnection manually for more control:Session Recovery
Recover session state after app restart:Background Execution
iOS Background Modes
For iOS, if you need limited background execution, configure inInfo.plist:
Background execution is limited on iOS. For long-running tasks, consider
using server-side processing with push notifications.
Android Keep-Alive
For Android apps that need to stay alive:SSE Streaming
The React Native SDK usesreact-native-sse for Server-Sent Events, which is bundled automatically. No additional configuration is required.
Differences from Web
Streaming State
TheuseJadeSession hook provides detailed streaming state for building rich UIs:
Building a Tool Execution UI
Complete Example
Best Practices
Use AsyncStorage or MMKV for general data persistence
Use Keychain for sensitive data like API keys
Let the SDK handle background pausing automatically
Show clear UI when streaming is paused
Persist session ID for recovery after app termination
Check session status before reconnecting
Use push notifications for long-running operations
Test background/foreground transitions thoroughly
Related
- JadeProvider - Provider configuration
- Hooks Reference - All available hooks
- Session Management - Session persistence patterns