Algolia Instantsearch with React

This tutorial is an extension of the [Algolia Cloud Functions Guide](/lessons/algolia-cloud-functions/). You must have the Cloud Functions deployed to start making instant search queries from your frontend app.

Install InstantSearch

Algolia provides official React support. Follow the installation steps to make the prebuilt components available in your app.

React InstantSearch Component

import React from 'react';
import './App.css';

import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, SearchBox, Hits, connectHighlight } from 'react-instantsearch-dom';

const searchClient = algoliasearch('YOUR-APP-ID', 'YOUR-SEARCH-KEY');

function App() {
  return (
    <InstantSearch searchClient={searchClient} indexName="customers">
      <SearchBox />
      <Hits hitComponent={Hit} />

const CustomHighlight = connectHighlight(({ highlight, attribute, hit }) => {
  const parsedHit = highlight({
    highlightProperty: '_highlightResult',

  return (
      <img src={hit.avatar} alt={hit.username} />
        part => part.isHighlighted ? <mark>{part.value}</mark> : part.value

const Hit = ({ hit }) => (
    <CustomHighlight attribute="bio" hit={hit} />

export default App;


Ask questions via GitHub below OR chat on Slack #questions