usePreviewSearch
Use the preview search query hook to request and retrieve data for preview search widgets.
Request parameters
| Name | Type | Description |
|---|---|---|
keyphrase | string | String to search for |
suggestionsList | array of strings | List of suggestions |
itemsPerPage | integer | Number of items on page. |
Generic response
Import
Example
Each suggestion in the suggestionsList parameter supports the keyphrase_fallback boolean parameter. When set to true, Search uses the first suggestion from the first suggestion block as an alternate keyword when there are no results for a search. See the sample code snippet:
Convert a UI component into a widget component before adding it to pages.
To convert a component into a widget component, pass the UI component to the widget or setWidget function.
These React resources can help you with your implementation:
-
To view working examples of widgets, visit the starter kit website built using Search JS SDK and UI components packages.
-
You can download or fork its GitHub repository.