API Reference / InstantSearch.js Widgets / singleIndex
Widget signature
instantsearch.stateMappings.singleIndex(
  indexName: string,
);

About this widget

The singleIndex state mapping enables backward compatibility with version 3.x.x.

Applies the following transformations:

  • omits the configure widget
  • uses the given index for the top level
1
2
3
4
5
6
7
8
9
10
11
12
13
14
instantsearch.stateMappings.singleIndex('instant_search').stateToRoute({
  instant_search: {
    query: 'Apple',
    page: 5,
    configure: {
      hitsPerPage: 4,
    },
  },
});

// {
//   query: 'Apple',
//   page: 5,
// }

Examples

1
2
3
4
5
6
instantsearch({
  // ...
  routing: {
    stateMapping: instantsearch.stateMappings.singleIndex('instant_search'),
  },
});

Options

indexName
type: string
Required

The name of the index to get the state from, usually the same value provided to instantsearch.

1
instantsearch.stateMappings.singleIndex('instant_search');

Did you find this page helpful?

InstantSearch.js v4