API Reference / React InstantSearch Hooks / <Index>
Signature
<Index
  indexName={string}
  // Optional props
  indexId={string}
/>

About this component

<Index> is the provider component for an Algolia index. It’s useful when you want to build an interface that targets multiple indices.

You can learn more about this federated search pattern in the guides on multi-index search.

The position of <Index> in the widget tree impacts which search parameters apply. Widgets that create search parameters forward them to their children <Index> widgets.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React from 'react';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, Index } from 'react-instantsearch-hooks-web';

const searchClient = algoliasearch(
  'YourApplicationID',
  'YourSearchOnlyAPIKey'
);

function App() {
  return (
    <InstantSearch indexName="instant_search" searchClient={searchClient}>
      {/* Widgets */}
      <Index indexName="instant_search_demo_query_suggestions">
        {/* Widgets */}
      </Index>
    </InstantSearch>
  );
}

Props

indexName
type: string
Required

The main index to search into.

1
2
3
<Index indexName="instant_search">
  {/* Widgets */}
</Index>
indexId
type: string

An identifier for the <Index> widget.

Providing an indexId allows different <Index widgets to target the same Algolia index. It’s especially useful for the routing feature, and lets you find the refinements that match an <Index> widget.

1
2
3
4
5
6
<Index
  // ...
  indexId="instant_search"
>
  {/* Widgets */}
</Index>
Did you find this page helpful?