recommend icon indicating copy to clipboard operation
recommend copied to clipboard

doc(readme): announce InstantSearch compatibility

Open Haroenv opened this issue 9 months ago • 1 comments

🙌 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 from 'instantsearch.js';
import {
  frequentlyBoughtTogether,
  relatedProducts,
} from 'instantsearch.js/es/widgets';
import algoliasearch from 'algoliasearch/lite';
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');

instantsearch({
  // No need for a recommendClient anymore
  searchClient,
  indexName,
}).addWidgets([
  frequentlyBoughtTogether({
    container: '#frequentlyBoughtTogether',
    objectIDs: [currentObjectID],
  }),
  relatedProducts({
    container: '#relatedProducts',
    objectIDs: [currentObjectID],
  }),
]);
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>
  );
}

FX-2846

Haroenv avatar May 16 '24 07:05 Haroenv