useDropboxBackup
useDropboxBackup(
options:object):UseDropboxBackupResult
Defined in: src/react/useDropboxBackup.ts:102
React hook for Dropbox backup and restore functionality.
This hook provides methods to backup conversations to Dropbox and restore them. It handles all the logic for checking timestamps, skipping unchanged files, authentication, and managing the backup/restore process.
Must be used within a DropboxAuthProvider.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Dropbox folder path for backups (default: ‘/ai-chat-app/conversations’) |
|
|
|
WatermelonDB database instance |
|
|
( |
Export a conversation to an encrypted blob |
|
|
( |
Import a conversation from an encrypted blob |
|
|
( |
Request encryption key for the user address |
|
|
|
Current user address (null if not signed in) |
Returns
Example
import { useDropboxBackup } from "@reverbia/sdk/react";
function BackupButton() {
const { backup, restore, isConfigured } = useDropboxBackup({
database,
userAddress,
requestEncryptionKey,
exportConversation,
importConversation,
});
const handleBackup = async () => {
const result = await backup({
onProgress: (current, total) => {
console.log(`Progress: ${current}/${total}`);
},
});
if ("error" in result) {
console.error(result.error);
} else {
console.log(`Uploaded: ${result.uploaded}, Skipped: ${result.skipped}`);
}
};
return <button onClick={handleBackup} disabled={!isConfigured}>Backup</button>;
}