Adding facets to instantsearch in next.js SSR

Hello,

I am currently able to search in nextjs using the recommended pattern

export const { InstantSearch, findResultsState } = createInstantSearch();

However in my results I am trying to get the facets returned as well because currently the facets property is just an empty object. How can I achieve this? I see in the documentation it says to do this

index.search({
  query: 'query',
  facets: ['category', 'author']
}).then(res => {
  // console.log(res);
});

but I dont see how this fits into the nextjs SSR pattern? Basically I need facets so I can have the refinement list component to enable filtering. Any help would be great!

The correct way to use this with Next is to make sure the RefinementList is mounted once you call findResultsState. There’s an example available using next which uses this pattern: