@algolia/recommend-react
v1.16.0
Published
React package for Algolia Recommend.
Downloads
66,204
Maintainers
Keywords
Readme
🙌 From now on you can use Algolia Recommend from InstantSearch, simplifying your integration between the two libraries!
Learn how to migrate following the upgrade guide.
import {
InstantSearch,
FrequentlyBoughtTogether,
RelatedProducts,
} from 'react-instantsearch';
import algoliasearch from 'algoliasearch/lite';
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
function App() {
return (
<InstantSearch searchClient={searchClient} indexName={indexName}>
<FrequentlyBoughtTogether objectIDs={[currentObjectID]} />
<RelatedProducts objectIDs={[currentObjectID]} />
</InstantSearch>
);
}
@algolia/recommend-react
React package for Algolia Recommend.
Installation
All Recommend packages are available on the npm registry.
yarn add @algolia/recommend-react
# or
npm install @algolia/recommend-react
Usage
Import the FrequentlyBoughtTogether
and RelatedProducts
and use them in your parent component.
import React from 'react';
import {
FrequentlyBoughtTogether,
RelatedProducts,
} from '@algolia/recommend-react';
import recommend from '@algolia/recommend';
const recommendClient = recommend('YourApplicationID', 'YourSearchOnlyAPIKey');
const indexName = 'YOUR_INDEX_NAME';
function App({ currentObjectID }) {
// ...
return (
<div>
<FrequentlyBoughtTogether
recommendClient={recommendClient}
indexName={indexName}
objectIDs={[currentObjectID]}
itemComponent={({ item }) => {
return (
<pre>
<code>{JSON.stringify(item)}</code>
</pre>
);
}}
/>
<RelatedProducts
recommendClient={recommendClient}
indexName={indexName}
objectIDs={[currentObjectID]}
itemComponent={({ item }) => {
return (
<pre>
<code>{JSON.stringify(item)}</code>
</pre>
);
}}
/>
</div>
);
}
Continue reading our Getting Started guide.
Documentation
The documentation offers a few ways to learn about the Recommend library:
- Follow the Building your Recommend UI guide to display recommendations on your website.
- Refer to the API reference for a comprehensive list of parameters and options.