useDeleteUserFavorite
Mutation hook that removes a previously pinned favorite by its server-assigned ID.
ℹ️
The hook reads the JWT from localStorage (key: azuro:auth:<address>:<affiliate>).
If no valid token is cached, it throws AuthError with code: 'NotAuthenticated'.
Call useAuth.signIn() from a user gesture before mutating,
then retry.
Usage
import { useAuth, useDeleteUserFavorite } from '@azuro-org/sdk'
const { isAuthenticated, signIn } = useAuth({ affiliate: '0x...' })
const { remove, isPending, error } = useDeleteUserFavorite({ affiliate: '0x...' })
const onRemoveFavorite = async (favoritesId: string) => {
if (!isAuthenticated) await signIn()
remove({ favoritesId })
}On success the hook automatically invalidates the useUserFavorites cache so the removed
entry disappears from the UI without a manual refetch.
Props
type UseDeleteUserFavoriteProps = {
affiliate: Address
chainId?: ChainId
onSuccess?: (data: DeleteUserFavoriteResult) => void
onError?: (err: Error) => void
}type ChainId =
| 137 // Polygon
| 80002 // Polygon Amoy
| 8453 // Base
| 84532 // Base SepoliaReturn Value
{
remove: (vars: DeleteUserFavoriteVariables) => void
removeAsync: (vars: DeleteUserFavoriteVariables) => Promise<DeleteUserFavoriteResult>
isPending: boolean
error: Error | null
}type DeleteUserFavoriteVariables = {
favoritesId: string // server-assigned ID from createUserFavorite or getUserFavorites
}type DeleteUserFavoriteResult = {
favoritesId: string // echoes the deleted entry's ID
success: boolean
}Last updated on