Skip to main content

Function: useAds()

useAds<TProduct>(props): UseAdsReturn<TProduct>

Defined in: useAds.tsx:81

Fetches and returns hydrated ads

If used outside of an AdsProvider, this hook degrades gracefully and returns a no-op result: empty ads, no error, not loading, and a noop refresh.

Type Parameters​

TProduct​

TProduct extends object

Parameters​

props​

UseAdsProps

Configuration object for the ad request including placement, type, amount, and optional search parameters

Returns​

UseAdsReturn<TProduct>

An object containing ads data, loading state, error information, and refresh function

Example​

const \{ ads, isLoading, error, refresh \} = useAds(\{
placement: "top",
type: "product",
amount: 3,
term: "camiseta",
selectedFacets: [\{ key: "brand", value: "Nike" \}],
\});