Docs
/
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 optional object with the following properties:

preferenceSetstring

The preference set ID to fetch. If not provided, the default preference set will be fetched.

tenantstring

Optional tenant ID for multi-tenant applications.

Returns

#

Returns an object with the following properties:

preferencesPreferenceSet | undefined

The preference set data including workflows and channels.

setPreferences(properties: SetPreferencesProperties) => void

Function to update user preferences.

getAllPreferences() => Promise<PreferenceSet[]>

Function to retrieve all preference sets for the user.

isLoadingboolean

Whether preferences are being loaded.

isValidatingboolean

Whether preferences are being revalidated.

Example

#

Basic usage

#

The following example demonstrates how to use the usePreferences hook to manage user preferences.

With tenant

#

For multi-tenant applications, you can specify a tenant:

Getting all preference sets

#

You can retrieve all preference sets for the user: