Skip to content

searchcraft-search-results

This web component is responsible for displaying the results of a search query. Once a query is submitted, the component formats and presents an ordered list of the results.

import { SearchcraftSearchResults } from "@searchcraft/react-sdk";
index.html
<searchcraft-search-results
ad-interval="4"
place-ad-at-start="true"
/>
index.js
const searchResults = document.querySelector('searchcraft-search-results');
searchResults.template = (item, index, { html }) => html`
<h2>${item.title}</h2>
`;
PropertyAttributeDescriptionTypeDefault
initialQueryinitial-queryA query that will appears when the component initializes or the search term is ”..string | undefinedundefined
searchcraftIdsearchcraft-idThe id of the Searchcraft instance that this component should use.string | undefinedundefined
templateA callback function responsible for rendering a result. Passed to searchcraft-search-result.((data: any, index: number, utils: { html: TemplateHtml; source_index?: string | undefined; }) => string) | undefinedundefined