Make changes to page on no results

I want to show a minimal page on an empty query or on a query yielding no results. I am building on the codepen here.

For the empty query, I used the logic described here to look at the request:

const searchClient = {
  search(requests) {
    if (requests.every(({ params }) => !params.query)) {
    } else {

In the case of no results, I’m happy to display “No results” in the hits container, but I want to get rid of the empty facet containers (unlike in the codepen).

How can I detect a “no results” response and make changes elsewhere on the page?

Well, I found a hacky solution based on the refinementList widget.

There must be a better way but for now, this works:

    container: '#org-list',
    attribute: 'Organization',
    transformItems(items) {
      if (items.length > 0) {
      } else {
        // do something else
      return items;