Giter VIP home page Giter VIP logo

catalyst-algolia's Introduction

Guide

Integrating Algolia SearchBox into Catalyst

You can integrate Algolia search into Catalyst storefronts to help shoppers search all products, categories, and more.

This guide demonstrates a basic integration and provides example code for global product search that you can add to the core code of your Catalyst storefront, or to apps/core in the Catalyst monorepo.

Demo site

For a working demo of an Algolia integration with Catalyst, see the following example:

https://catalyst-algolia.vercel.app/

Prerequisites

To follow this guide, you need the following:

Steps

  1. Configure the core codebase for the Catalyst storefront and get it running in dev mode. See CLI setup for quickstart instructions. If you configure Catalyst using the Monorepo, make sure the storefront is associated with a BigCommerce store channel.

  2. At the top of your Algolia dashboard, create an Algolia app that you intend to associate exclusively with your Catalyst storefront channel.

  3. Install the BigCommerce Algolia app and associate it with your Catalyst channel. Add the following Algolia-specific environment variables to the existing .env.local file in your Catalyst storefront. For more about other Catalyst environment variables, see Environment variables.

Environment variable Value
NEXT_PUBLIC_ALGOLIA_APP_ID Your Algolia app ID
NEXT_PUBLIC_ALGOLIA_API_KEY Your Algolia Search Only API key. You can find this value in the API keys > All API keys section of your Algolia account dashboard. If this is your first time using the new Algolia app, visit the Search > Index section of the Algolia dashboard and click the Refresh index button to generate your search index.
NEXT_PUBLIC_ALGOLIA_INDEXNAME Your Algolia Search Index name. By Defualt the BigCommerce Algolia app uses the index name Bigcommerce.
  1. Install the following dependencies in your Catalyst storefront:
  npm i react-instantsearch
  npm i -S algoliasearch
  1. Update the files in your Catalyst /components/quick-search directory to include the code from the Algolia example repo /components/quick-search directory
  • Add the algoliaSearchBox.tsx and algoliaSearchHits.tsx files
  • Update the index.tsx file

Your storefront's file tree will mirror the following screenshot.

A file tree with a components/quick-seach directory that contains the same files as the Algolia example repo

  1. In components/quick-search/index.tsx, update the value of algoliaClient to use your correct indexName. By default, the BigCommerce Algolia app names the search index BigCommerce.

  2. Start your Catalyst storefront app in dev mode. Check the QuickSearch box to see the data supplied by the Algolia app index.

pnpm run dev

Resources

catalyst-algolia's People

Contributors

gje4 avatar katiehoesley avatar bc-andreadao avatar

Watchers

 avatar

Forkers

slsriehl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.