Packages
Add thereact-instantsearch and algoliasearch packages to your project,
and remove the @algolia/recommend and @algolia/recommend-js packages:
Imports
Import the Recommend components from React InstantSearch:React
- The
TrendingFacetscomponent - The
useTrendingFacetsHook - The
useRecommendationsHook - The
Recommendcontext provider
Usage
Recommend widget must be children of theInstantSearch component.
Pass the API client and index name to the InstantSearch component:
React
Components
| Recommend React | React InstantSearch | Changes |
|---|---|---|
FrequentlyBoughtTogether | FrequentlyBoughtTogether | Prop changes |
RelatedProducts | RelatedProducts | Prop changes |
TrendingItems | TrendingItems | Prop changes |
TrendingFacets | Removed | Alternative |
LookingSimilar | LookingSimilar | Prop changes |
Recommend | Removed | Alternative |
Changes for FrequentlyBoughtTogether
Move recommendClient and indexName to InstantSearch
The FrequentlyBoughtTogether component no longer needs recommendClient and indexName props. Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace children and view with the layoutComponent prop or the useFrequentlyBoughtTogether Hook
The FrequentlyBoughtTogether component no longer provides children and view props.
To fully customize the UI, use either the layoutComponent prop or the useFrequentlyBoughtTogether Hook instead.
Layout
Hook
Replace fallbackComponent with emptyComponent
The emptyComponent prop replaces the fallbackComponent prop.
React
Replace maxRecommendations with limit
The limit prop replaces the maxRecommendations prop.
React
Remove environment
The environment prop is no longer needed.
React
Replace classNames
The classNames keys have changed.
React
Changes for RelatedProducts
Move recommendClient and indexName to InstantSearch
The RelatedProducts component no longer needs recommendClient and indexName props. Instead, pass a searchChlient and the ìndexName to <InstantSearch>.
React
Replace children and view with the layoutComponent prop or the useRelatedProducts() Hook
The RelatedProducts component no longer provides children and view props.
To fully customize the UI, use either the layoutComponent prop or the useRelatedProducts Hook instead.
Layout
Hook
Replace fallbackComponent with emptyComponent
The emptyComponent prop replaces the fallbackComponent prop.
React
Replace maxRecommendations with limit
The limit prop replaces the maxRecommendations prop.
The RelatedProducts component now takes an optional maxRecommendations prop which replaces limit.
React
Remove environment
The environment prop is no longer needed.
React
Replace classNames
The classNames keys have changed.
React
Changes for TrendingItems
Move recommendClient and indexName to InstantSearch
The TrendingItems component no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace children and view with the layoutComponent prop or the useTrendingItems() Hook
The TrendingItems component no longer provides children and view props.
To fully customize the UI, use either the layoutComponent prop or the useTrendingItems Hook instead.
Layout
Hook
Replace fallbackComponent with emptyComponent
The emptyComponent prop replaces the fallbackComponent prop.
React
Replace maxRecommendations with limit
The limit prop replaces the maxRecommendations prop.
React
Remove environment
The environment prop is no longer needed.
React
Replace classNames
The classNames keys have changed.
React
Alternative for TrendingFacets
The TrendingFacets component isn’t available in React InstantSearch.
If you need it, use the TrendingFacets component from the deprecated Recommend React library.
Changes for LookingSimilar
Move recommendClient and indexName to InstantSearch
The LookingSimilar component no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace children and view with the layoutComponent prop or the useLookingSimilar() Hook
The LookingSimilar component no longer provides children and view props.
To fully customize the UI, use either the layoutComponent prop or the useLookingSimilar Hook instead.
Layout
Hook
Replace fallbackComponent with emptyComponent
The emptyComponent prop replaces the fallbackComponent prop.
React
Replace maxRecommendations with limit
The limit prop replaces the maxRecommendations prop.
React
Remove environment
The environment prop is no longer needed.
React
Replace classNames
The classNames keys have changed.
React
Hooks
| Recommend React | React InstantSearch | Changes |
|---|---|---|
useFrequentlyBoughtTogether | useFrequentlyBoughtTogether | Prop changes |
useRelatedProducts | useRelatedProducts | Prop changes |
useTrendingItems | useTrendingItems | Prop changes |
useTrendingFacets | Removed | Alternative |
useLookingSimilar | useLookingSimilar | Prop changes |
useRecommendations | Removed | Alternative |
Changes for useFrequentlyBoughtTogether
Move recommendClient and indexName to InstantSearch
The useFrequentlyBoughtTogether Hook no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace recommendations with items
The useFrequentlyBoughtTogether Hook returns recommendations under the items key instead of recommendations.
React
Changes for useRelatedProducts
Move recommendClient and indexName to InstantSearch
The useRelatedProducts Hook no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace recommendations with items
The useRelatedProducts Hook returns recommendations under the items key instead of recommendations.
React
Changes for useTrendingItems
Move recommendClient and indexName to InstantSearch
The useTrendingItems Hook no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace recommendations with items
The useTrendingItems Hook returns recommendations under the items key instead of recommendations.
React
Alternative for useTrendingFacets
The useTrendingFacets Hook isn’t available in React InstantSearch.
If you need it, use the useTrendingFacets Hook from the deprecated Recommend React library.
Alternative for useRecommendations
The useRecommendations Hook isn’t available in React InstantSearch.
Instead, use the dedicated Hooks for each Recommend model.
Changes for useLookingSimilar
Move recommendClient and indexName to InstantSearch
The useLookingSimilar Hook no longer needs recommendClient and indexName props.
Instead, pass a searchChlient and the ìndexName to InstantSearch.
React
Replace recommendations with items
The useLookingSimilar Hook returns recommendations under the items key instead of recommendations.
React
Remove Recommend context provider
The Recommend context provider is no longer necessary to batch requests.
Remove it from your implementation.
React
HorizontalSlider
The HorizontalSlider component is now available in React InstantSearch as the Carousel component.
For Carousel props, check the API reference: