Skip to main content
This guide describes how to integrate Algolia into a headless Salesforce B2C Commerce storefront using a custom React frontend. Unified InstantSearch for ecommerce for a Salesforce B2C Commerce headless storefront

Open CodeSandbox

Run and edit the Algolia with a custom React frontend example in CodeSandbox.

Explore source code

Browse the source for the Algolia with a custom React frontend example on GitHub.
To set up Algolia for your headless Salesforce B2C Commerce storefront, see Headless commerce.

Set up a React project

This guide uses Next.js but you can apply the instructions to any React project. Create a new Next.js app with the create-next-app command-line tool.
Command line
Running this command creates a new project in the directory my-react-storefront and starts a local development server on http://localhost:3000/.

Build your search experience

To create the search experience, you can either:
  1. Use the Unified InstantSearch package.
  2. Build a custom experience with React InstantSearch.
This guide uses the Unified InstantSearch package.

Download and run Unified InstantSearch

Clone the Unified InstantSearch GitHub repository.
Command line

Configure Unified InstantSearch for your data

Open the file unified-instantsearch-ecommerce/src/config/settings.js and make the following changes:
  1. Add your Algolia , search , and name:
    JavaScript
  2. Configure your replica indices for sorting by “price” in ascending and descending order:
    JavaScript
  3. Configure your category attributes. By default, the Algolia cartridge indexes the primary category on the attributes __primary_category.*:
    JavaScript
  4. Set your price attribute. By default, the Algolia cartridge indexes prices on the attributes price.${currency}:
    JavaScript
  5. Optional: remove query suggestions. If you don’t have Query Suggestions set up, remove the following code:
    JavaScript
  6. Customize the Hit component:
    JSX
    The <Hit> component includes code for sending click events when users select a product in the search results.

Export the project

To make your frontend available in your storefront, you need to export it:
Command line
Running this command creates a new directory unified-instantsearch-ecommerce/export with all assets. Copy this directory to the public directory of your storefront project.
Command line

Create a new Search component

To use your React frontend in your storefront, create a new Search component in the components directory.
Command line
Add the following code to the file Search.js:
JavaScript

Use your Search component in your storefront

Open the file pages/index.js with your Home component and add your Search component to it.

Click and conversion events

To complete your setup, send click and conversion events.
Last modified on July 14, 2026