Hi, I am trying to implement vue-instantsearch for...
# community-help
m
Hi, I am trying to implement vue-instantsearch for typesense at vue storefront. But getting below error. Please help me to implement this feature with Vue Storefront.
k
Hi Mehul, can you please post the code snippet that triggers this error?
m
Copy code
<template>
  <ais-instant-search-ssr>
    <ais-index
      index-name="instant_search_demo_query_suggestions"
      index-id="querySuggestions"
    >
      <ais-search-box />
      <ais-configure :hits-per-page.camel="5" />
      <ais-hits>
        <template v-slot:item="{ item }">
          <ais-highlight
            attribute="query"
            :hit="item"
          />
        </template>
      </ais-hits>
      <ais-pagination />
    </ais-index>
    <ais-search-box />
    <ais-stats />
    <ais-index
      index-id="refinement"
      index-name="instant_search"
    >
      <ais-refinement-list attribute="brand" />
    </ais-index>
    <ais-hits>
      <template v-slot:item="{ item }">
        <p>
          <ais-highlight
            attribute="name"
            :hit="item"
          />
        </p>
        <p>
          <ais-highlight
            attribute="brand"
            :hit="item"
          />
        </p>
      </template>
    </ais-hits>
    <ais-pagination />
  </ais-instant-search-ssr>
</template>

<script>
import {
  AisInstantSearchSsr,
  AisIndex,
  AisConfigure,
  AisRefinementList,
  AisHits,
  AisHighlight,
  AisSearchBox,
  AisStats,
  AisPagination
} from 'vue-instantsearch';
import { typesense } from 'config'
import TypesenseInstantSearchAdapter from 'typesense-instantsearch-adapter';
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: typesense,
  cacheSearchResultsForSeconds: 2 * 60,
  additionalSearchParameters: {
    perPage: 50,
    length: 50,
    queryBy: 'product_name,sku',
  },
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

export default {
  components: {
    AisInstantSearchSsr,
    AisIndex,
    AisConfigure,
    AisRefinementList,
    AisHits,
    AisHighlight,
    AisSearchBox,
    AisStats,
    AisPagination,
  },
  head() {
    return {
      link: [
        {
          rel: 'stylesheet',
          href:
            '<https://unpkg.com/instantsearch.css@7.1.0/themes/algolia-min.css>',
        },
      ],
    };
  },
};
</script>

<style>
.ais-Hits-list {
  text-align: left;
}
.ais-Hits-list:empty {
  margin: 0;
}
.ais-InstantSearch {
  margin: 1em;
}
</style>
j
@Mehul Savaliya It looks like you might need to get the vue storefront build process to transpile vue-instantsearch first. For eg, I found a very similar issue with another library when used with Nuxt: https://github.com/nuxt/nuxt.js/issues/9223#issuecomment-834832352 I'm not familiar with Vue storefront, but may be there's a way to do the same thing in vue-storefront as well?