Upgrade from Recommend JS to InstantSearch.js
The Recommend widgets are part of InstantSearch.js. Learn how you can upgrade from Recommend JS.
The widgets for displaying recommendations are part of InstantSearch.js, starting with version 4.69.0. The Algolia JavaScript API client supports the Recommend API starting with version 4.23.2. With this, you can integrate recommendations seamlessly into your InstantSearch app, without having to install additional packages.
Packages
Add the instantsearch.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:
The trendingFacets
function is no longer available.
To replace it, see widgets.
Usage
Add the Recommend widgets to the instantsearch
component.
Pass the API client and index name to the instantsearch
widget:
Widgets
Recommend JS | InstantSearch.js | Changes |
---|---|---|
frequentlyBoughtTogether | frequently-bought-together | Prop changes |
relatedProducts | related-products | Prop changes |
trendingItems | trending-items | Prop changes |
trendingFacets | Removed | Alternative |
lookingSimilar | looking-similar | Prop changes |
Changes for frequentlyBoughtTogether
Move recommendClient
and indexName
to instantsearch
The frequently-bought-together
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchClient
and the ìndexName
to instantsearch
.
Replace view
with the layout
template or the connectFrequentlyBoughtTogether
connector
The frequently-bought-together
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the frequently-bought-together
connector instead.
Layout template
Connector
Replace component props with templates
The frequently-bought-together
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 frequently-bought-together
widget uses templates to provide translations to the header.
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
Remove environment
The environment
prop is no longer needed.
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
Changes for relatedProducts
Move recommendClient
and indexName
to instantsearch
The related-products
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchChlient
and the ìndexName
to instantsearch
.
Replace view
with the layout
template or the connectRelatedProducts
connector
The related-products
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the related-products
connector instead.
Layout template
Connector
Replace component props with templates
The related-products
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 related-products
widget uses templates to provide translations to the header.
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
Remove environment
The environment
prop is no longer needed.
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
Changes for trendingItems
Move recommendClient
and indexName
to instantsearch
The trending-items
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchClient
and the ìndexName
to instantsearch
.
Replace view
with the layout
template or the connectTrendingItems
connector
The trending-items
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the trending-items
connector instead.
Layout template
Connector
Replace component props with templates
The trending-items
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 trending-items
widget uses templates to provide translations to the header.
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
Remove environment
The environment
prop is no longer needed.
Replace classNames
with cssClasses
The cssClasses
prop replaces the classNames
prop.
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
The looking-similar
widget no longer needs recommendClient
and indexName
props.
Instead, pass a searchChlient
and the ìndexName
to instantsearch
.
Replace view
with the layout
template or the connectLookingSimilar
connector
The looking-similar
widget no longer provides a view
prop.
To fully customize the UI, use either the layout
template or the looking-similar
connector instead.
Layout template
Connector
Replace component props with templates
The looking-similar
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 looking-similar
widget uses templates to provide translations to the header.
Replace maxRecommendations
with limit
The limit
prop replaces the maxRecommendations
prop.
Remove environment
The environment
prop is no longer needed.
Replace classNames
with cssClasses
The classNames
keys have changed and are defined through the cssClasses
prop.
horizontalSlider
The horizontalSlider
view is now available in InstantSearch.js as a carousel
template.
For carousel options, check the API reference:
frequentlyBoughtTogether
relatedProducts
- `trendingItems
lookingSimilar
Was this page helpful?