useGoogleDriveBackup
useGoogleDriveBackup(
options:object):UseGoogleDriveBackupResult
Defined in: src/react/useGoogleDriveBackup.ts:105
React hook for Google Drive backup and restore functionality.
This hook provides methods to backup conversations to Google Drive 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 GoogleDriveAuthProvider.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Subfolder for conversations (default: ‘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 |
|
|
|
Root folder name in Google Drive (default: ‘ai-chat-app’) |
|
|
|
Current user address (null if not signed in) |
Returns
Example
import { useGoogleDriveBackup } from "@reverbia/sdk/react";
function BackupButton() {
const { backup, restore, isConfigured, isAuthenticated } = useGoogleDriveBackup({
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>;
}