Announcing the instantsearch pattern router!

We are happy to announce a new way to do routing in InstantSearch, via path patterns!

// either via import:
import { patternRouter, windowEnvironment } from 'instantsearch-pattern-router';
// or via umd:
const { patternRouter, windowEnvironment } = window.instantsearchPatternRouter;

instantsearch({
  routing: {
    router: patternRouter({
      pattern: '/search/:hierarchy*/c/category?',
      environment: windowEnvironment,
      // optional
      windowTitle: ({ category }) => `My Site Search — ${category}`,
      writeDelay: 400,
    }),
    // required to flatten to one level
    stateMapping: myFlattenMapping,
  },
});

Check it out: https://github.com/algolia/instantsearch-pattern-router

If you’re using this, don’t hesitate to reach out!

2 Likes