useSettings
useSettings(
options:object):UseSettingsResult
Defined in: src/react/useSettings.ts:117
A React hook for managing user settings with automatic persistence using WatermelonDB.
Multiple components calling this hook with the same (database, walletAddress)
share a single underlying fetch and observe subscription — without this
deduplication, every consumer would pay an extra worker-bridge round-trip
per mount and trigger WatermelonDB’s “raw object sent over the bridge”
warning. See userSettingsStore.ts for the pool implementation.
The hook supports both the legacy modelPreference API (deprecated) and
the new unified userPreference API that stores profile data, model preferences,
and personality settings in a single table.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Configuration options |
|
|
|
The WatermelonDB instance. May be |
|
|
|
‐ |
Returns
An object containing settings state and methods
Example
import { Database } from '@nozbe/watermelondb';
import { useSettings } from '@anuma/sdk/react';
function SettingsComponent({ database }: { database: Database }) {
const {
userPreference,
isLoading,
setUserPreference,
updateProfile,
updatePersonality,
} = useSettings({
database,
walletAddress: '0x123...', // Auto-loads and migrates preference
});
const handleProfileUpdate = async () => {
await updateProfile('0x123...', {
nickname: 'John',
occupation: 'Developer',
});
};
return (
<div>
<p>Nickname: {userPreference?.nickname ?? 'Not set'}</p>
<button onClick={handleProfileUpdate}>Update Profile</button>
</div>
);
}