Packages
Add theinstantsearch.js
and algoliasearch
packages to your project,
and remove the @algolia/recommend
and @algolia/recommend-js
packages:
Imports
Import the Recommend widgets from InstantSearch.js:JavaScript
The
trendingFacets
function is no longer available.
To replace it, see widgets.Usage
Add the Recommend widgets to theinstantsearch
component.
Pass the API client and index name to the instantsearch
widget:
JavaScript
Widgets
Recommend JS | InstantSearch.js | Changes |
---|---|---|
frequentlyBoughtTogether | frequentlyBoughtTogether | Prop changes |
relatedProducts | relatedProducts | Prop changes |
trendingItems | trendingItems | Prop changes |
trendingFacets | Removed | Alternative |
lookingSimilar | lookingSimilar | Prop changes |
Changes for frequentlyBoughtTogether
Move recommendClient
and indexName
to instantsearch
The frequentlyBoughtTogether
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchClient
and the ìndexName
to instantsearch
.
JavaScript
Replace view
with the layout
template or the connectFrequentlyBoughtTogether
connector
The frequentlyBoughtTogether
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the connectFrequentlyBoughtTogether
connector instead.
Layout template
JavaScript
Connector
JavaScript
Replace component props with templates
The frequentlyBoughtTogether
widget uses templates to customize specific parts of its UI.
Recommend JS | InstantSearch.js |
---|---|
headerComponent | header |
itemComponent | item |
fallbackComponent | empty |
Replace translations
with templates
The frequentlyBoughtTogether
widget uses templates to provide translations to the header.
JavaScript
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
JavaScript
Remove environment
The environment
prop is no longer needed.
JavaScript
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
JavaScript
Changes for relatedProducts
Move recommendClient
and indexName
to instantsearch
The relatedProducts
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchChlient
and the ìndexName
to instantsearch
.
JavaScript
Replace view
with the layout
template or the connectRelatedProducts
connector
The relatedProducts
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the connectRelatedProducts
connector instead.
Layout template
JavaScript
Connector
JavaScript
Replace component props with templates
The relatedProducts
widget uses templates to customize specific parts of its UI.
Recommend JS | InstantSearch.js |
---|---|
headerComponent | header |
itemComponent | item |
fallbackComponent | empty |
Replace translations
with templates
The relatedProducts
widget uses templates to provide translations to the header.
JavaScript
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
JavaScript
Remove environment
The environment
prop is no longer needed.
JavaScript
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
JavaScript
Changes for trendingItems
Move recommendClient
and indexName
to instantsearch
The trendingItems
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchClient
and the ìndexName
to instantsearch
.
JavaScript
Replace view
with the layout
template or the connectTrendingItems
connector
The trendingItems
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the connectTrendingItems
connector instead.
Layout template
JavaScript
Connector
JavaScript
Replace component props with templates
ThetrendingItems
widget uses templates to customize specific parts of its UI.
Recommend JS | InstantSearch.js |
---|---|
headerComponent | header |
itemComponent | item |
fallbackComponent | empty |
Replace translations
with templates
The trendingItems
widget uses templates to provide translations to the header.
JavaScript
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
JavaScript
Remove environment
The environment
prop is no longer needed.
JavaScript
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
JavaScript
Alternative for trendingFacets
InstantSearch.js doesn’t include a widget for trendingFacets
.
If you need it, use the trendingFacets
function
from the deprecated Recommend JS library.
Changes for lookingSimilar
Move recommendClient and indexName to instantsearch
ThelookingSimilar
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchChlient
and the ìndexName
to instantsearch
.
JavaScript
Replace view
with the layout
template or the connectLookingSimilar
connector
The lookingSimilar
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the connectLookingSimilar
connector instead.
Layout template
JavaScript
Connector
JavaScript
Replace component props with templates
The lookingSimilar
widget uses templates to customize specific parts of its UI.
Recommend JS | InstantSearch.js |
---|---|
headerComponent | header |
itemComponent | item |
fallbackComponent | empty |
Replace translations with templates
The lookingSimilar
widget uses templates to provide translations to the header.
JavaScript
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
JavaScript
Remove environment
The environment
prop is no longer needed.
JavaScript
Replace classNames
with cssClasses
The classNames
keys have changed and are defined through the cssClasses
prop.
JavaScript
horizontalSlider
The horizontalSlider
view is now available in InstantSearch.js as a carousel
template.
For carousel options, check the API reference:
JavaScript