🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
UI libraries / InstantSearch.js / Widgets
Signature
const routing = {
  stateMapping: simple(),
};
Import
1
import { simple } from 'instantsearch.js/es/lib/stateMappings';

About this widget

You are currently reading the documentation for InstantSearch.js V4. Read our migration guide to learn how to upgrade from V3 to V4. You can still access the V3 documentation for this page.

This simple state mapping is the default for the instantsearch object’s routing option.

The router provides an API that lets you customize some of its behaviors. To get a sense of what you can do with the API, see the Routing URLs guide.

The only transformation applied by the function is the omission of configure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
simple().stateToRoute({
  instant_search: {
    query: 'Apple',
    page: 5,
    configure: {
      hitsPerPage: 4,
    },
  },
});

// gives as output:
// {
//   instant_search: {
//     query: 'Apple',
//     page: 5,
//   },
// }

Examples

1
2
3
4
5
6
instantsearch({
  // ...
  routing: {
    stateMapping: simple(),
  },
});
Did you find this page helpful?