Category listing with search.js

Search.js can be used to render category listings. Category listing is a search, where the search input consists of only filters (to set filter for the category) and no query. If you wanted to list all products belonging to a category via API, you would send a request like /search?f[]=category:T-shirts. This request would return a list of all products for that category, sorted by Luigi's Box AI and respecting all merchandizig rules that you have set up.

There is almost nothing special about category listing from the initialization perspective. Follow the same setup as when initializating search including the loading placeholder for best UX.

IntentFilters: {
  category: 'T-shirts'
},

To set the filter for category, use a special-purpose IntentFilters configuration. Intent filters are designed to only persist for the duration of user's intent. Browsing the category listing is an intent and when the user decides to start searching, the intent changes, and the intent filters void. Note that the intent is an implicit concept inside search.js and there's no way to control it from outside.

If possible, use a more precise filtering by category ID, instead of its name.