Before you begin
To integrate your guides, you need frontend development proficiency with HTML, CSS, JavaScript, and React. You should also have created your guides. On this page, React is used to illustrate the integration process. However, the generative experiences client offers widgets for React and JavaScript. For more information, see Alternative implementations.Installation
Install the@algolia/generative-experiences-react package:
Set up the commerce client
The commerce client interacts with the Algolia Commerce API and is crucial for fetching the necessary data for the widgets:JavaScript
appId. Your Algolia application ID.indexName. The Algolia index used for generating and displaying guides.searchOnlyAPIKey. The Algolia search API key needed for reading index data. ACLs needed:search.region. The region of your Algolia application, eithereuorus. Default:us.
Display guide
Guides contain content and headlines.Display guide content
To show the content of a guide, use theGuideContent widget.
For more information, see GuideContent.
React

Display guide headlines
To reference your website’s guides, use theGuidesHeadlines widget.
This widget can be embedded in your home page, product detail page,
or search pages, and customized to display headlines based on categories or specific records.
For more information, see GuidesHeadlines.
React

Gather feedback
To gather feedback on the Guides you can use theGuidesFeedback widget.
You can use this widget directly in a Guide Content page,
or when you are displaying the Guide Headlines,
by passing showFeedback parameters in the GuideContent or GuidesHeadlines widgets.
Or you can add it and customize it separately, using the GuidesFeedback widget.
For more information, see GuidesFeedback.
This feature uses the Insights API to gather events related to Guides feedback.
This requires a user token.
React
Display website-specific content
Some of the generated guides may contain placeholders for website-specific content. These are used for the links to the product pages, guide pages as well as images. To replace these placeholders with your website-specific content, use thegetters parameter.
React
Parameters
guideURL. Returns the URL for a specific guide. This is used to link to the guide page from the guide headlines widget. The expected output is a string that represents the URL of the guide page.objectURL. Returns the URL for a specific product. This is used to link to the product page from the guide content widget. The expected output is a string that represents the URL of the product page.images. Returns a list of images for a product. This is used to display images in the guide headlines and guide content widgets. The expected output is an array of objects, each containing thesrcandaltproperties.
Customize styles
The widgets are unstyled by default. You can style them with theclassNames property or by applying your CSS to the existing classes.
With the classNames property
Use the classNames property to add classes to the widgets.
React
With Tailwind CSS
To integrate the widgets with Tailwind, include the@tailwindcss/typography plugin in your tailwind.config.js and add the following CSS to your project.
CSS