@algolia/recommend-js
TypeScript icon, indicating that this package has built-in type declarations

1.15.0 • Public • Published

@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:

/@algolia/recommend-js/

    Package Sidebar

    Install

    npm i @algolia/recommend-js

    Weekly Downloads

    1,313

    Version

    1.15.0

    License

    MIT

    Unpacked Size

    322 kB

    Total Files

    63

    Last publish

    Collaborators

    • wwalser
    • jkaho
    • mprevell97
    • louishousiaux
    • antoine.gilles
    • eventexperiences_algolia
    • jsok_algolia
    • bhinchley-algolia
    • hugowit
    • alg-admin
    • aymeric.giraudet
    • gavinwade12
    • bhcastle
    • rishi_algolia
    • jasonberry
    • scyganek-algolia
    • drodriguln
    • abodelot
    • leviwhalen
    • sfaiqh
    • valentindotxyz
    • fluf
    • instantsearch-bot
    • taylorcjohnson_algolia
    • pjankowski5312
    • raed-algolia
    • dylantientcheu
    • catalgolia
    • morgan-algolia
    • algabet
    • andy_ds
    • bengreenbank
    • alg-bgastinne
    • daltondickalgolia
    • jcohonner-algolia
    • robertmogos
    • mariaalungu
    • emmanuel.fortin
    • ejaldorau
    • dhaya.b
    • lukyvj
    • marielaure
    • haroenv
    • rayrutjes
    • jerska
    • ronanlevesque
    • samouss
    • therealwebby
    • francoischalifour
    • jonmontane
    • tkrugg
    • seafoox
    • sylvainh
    • clemfromspace
    • lorrissaintgenez
    • broujo
    • e-krebs
    • kombucha
    • sylvain
    • crawler-team
    • amcdaid106
    • devinalgolia
    • jvenezia
    • otomatik
    • sophiem03
    • sarahdayan
    • dcoates
    • maximehuang
    • guitek
    • matthewbond
    • cyril.descossy
    • tatsuro
    • danajeremy
    • mathougui
    • xavdh
    • agdavid
    • rasemotte
    • plnech
    • shortcuts
    • praagyajoshi
    • loicsay
    • svensoldin
    • alphonseb
    • leodau
    • fabienmotte
    • sarahfranc
    • millotp