In-App UI
React
Hooks
usePreferences
usePreferences
The usePreferences
hook is used to fetch and manage user notification preferences. This hook provides access to preference sets and allows you to update user preferences.
Parameters#
Accepts an object (UsePreferencesParams
) with the following properties:
preferenceSetstring
The preference set ID to fetch. If not provided, the default preference set will be fetched.Returns#
A UsePreferencesReturn
object with the following properties:
preferencesPreferenceSet
The preference set data including workflows and channels.isLoadingboolean
Whether preferences are being loaded.errorError | null
Error object if the request failed.updatePreferences(updates: PreferenceUpdate) => Promise<void>
Function to update user preferences.Example#
Basic usage#
The following example demonstrates how to use the usePreferences
hook to manage user preferences.