1.14.0 • Published 3 months ago

@algolia/recommend-js v1.14.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@algolia/recommend-js

JavaScript package for Algolia Recommend.

Installation

All Recommend packages are available on the npm registry.

yarn add @algolia/recommend-js
# or
npm install @algolia/recommend-js

Usage

To get started, you need a container for your recommendations to go in—in this guide, one for Frequently Bought Together, and one for Related Products. If you don't have containers already, you can insert them into your markup:

<div id="frequentlyBoughtTogether"></div>
<div id="relatedProducts"></div>

Then, insert your recommendations by calling the frequentlyBoughtTogether function and providing the container. It can be a CSS selector or an Element.

The process is the same for relatedProducts.

/** @jsx h */
import { h } from 'preact';
import {
  frequentlyBoughtTogether,
  relatedProducts,
} from '@algolia/recommend-js';
import recommend from '@algolia/recommend';

const recommendClient = recommend('YourApplicationID', 'YourSearchOnlyAPIKey');
const indexName = 'YOUR_INDEX_NAME';
const currentObjectID = 'YOUR_OBJECT_ID';

frequentlyBoughtTogether({
  container: '#frequentlyBoughtTogether',
  recommendClient,
  indexName,
  objectIDs: [currentObjectID],
  itemComponent({ item }) {
    return (
      <pre>
        <code>{JSON.stringify(item)}</code>
      </pre>
    );
  },
});

relatedProducts({
  container: '#relatedProducts',
  recommendClient,
  indexName,
  objectIDs: [currentObjectID],
  itemComponent({ item }) {
    return (
      <pre>
        <code>{JSON.stringify(item)}</code>
      </pre>
    );
  },
});

Continue reading our Getting Started guide.

Documentation

The documentation offers a few ways to learn about the Recommend library:

1.14.0

3 months ago

1.13.0

3 months ago

1.12.1

4 months ago

1.12.0

4 months ago

1.11.0

5 months ago

1.9.0

10 months ago

1.10.0

8 months ago

1.8.2

11 months ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.2.0

2 years ago

1.3.0

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago