UI libraries / React InstantSearch / Widgets

This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.

If you were using React InstantSearch v6, you can upgrade to v7.

If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.

If you want to keep using React InstantSearch v6, you can find the archived documentation.

Signature
<Index
  indexName={string}
  // Optional props
  indexId={string}
/>
Import
1
import { Index } from 'react-instantsearch';

About this widget

<Index> is the provider component for an Algolia index.

It’s useful when building interfaces that target multiple indices such as federated searches.

The position of <Index> in the widget tree affects 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 { liteClient as algoliasearch } from 'algoliasearch/lite';
import { InstantSearch, Index } from 'react-instantsearch';

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 lets different <Index widgets target the same Algolia index. It’s helpful for routing. It 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?