🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
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 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';

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

Parameter Description
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?