Skip to main content
Signature
import { simple } from "instantsearch.js/es/lib/stateMappings";

const routing = {
  stateMapping: simple(),
};

About this widget

This simple state mapping is the default for the ais-instant-search wrapper’s routing prop. The router provides an API that lets you customize some of its behaviors. For more information, see Routing URLs. The only transformation applied by the function is the omission of configure.
JavaScript
import { simple } from "instantsearch.js/es/lib/stateMappings";

simple().stateToRoute({
  instant_search: {
    query: "Apple",
    page: 5,
    configure: {
      hitsPerPage: 4,
    },
  },
});

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

Examples

Vue
<template>
  <ais-instant-search [...] :routing="routing">
    <!-- Widgets -->
  </ais-instant-search>
</template>

<script>
import { simple } from "instantsearch.js/es/lib/stateMappings";

export default {
  data() {
    return {
      // ...
      routing: {
        stateMapping: simple(),
      },
    };
  },
};
</script>
I