This module exposes composables that are auto-imported by Nuxt 3.
For more details check out the official documentation of initializing algolia client here
useAlgoliaSearchUse this composable to search the index by certain query and optional request options
<script setup>const { result, search } = useAlgoliaSearch('test_index') // pass your index name as paramonMounted(async () => { await search({ query: 'Samsung' });})</script>result will contain a value of a search method. It is reactive computed property that will be populated when a search method will fulfill. This result will have a form described heresearch method is used to fetch the results by the index and populates result reactive property. This method requires a parameter query and accepts an optional parameter of requestOptions that you can check out hereFor more details check out the official documentation of this method here
useAlgoliaFacetedSearchUse this composable to search using facet values like category, phone.
<script setup>const { result, search } = useAlgoliaFacetedSearch('test_index')onMounted(async () => { const facet = { name: 'category', query: 'phone' } await search({ facet })})</script>result will contain a value of a search method. It is reactive computed property that will be populated when a search method will fulfill. This result will have a form described heresearch method is used to fetch the results by the certain facet value pairs like name and query, and populates result reactive property. This method requries a parameter for facet and accepts an optional parameter of requestOptions that you can check out hereFor more details about using this search method check out the official documentation here
useAlgoliaRecommendUse this composable to get the recommendations matching certain criteria optional request options.
recommend property to true in algolia configuration in nuxt.config.ts.<script setup>const { result, get } = useAlgoliaRecommend()onMounted(async () => { await get({ queries: [{ indexName: 'test_index', model: 'related-products', objectID: 'dca44dd5-aea6-4553-a3af-fcbda981a2ef' }] });})</script>result will contain a value of a get method. It is reactive computed property that will be populated when a get method will fulfill. This result will have a form described hereget method is used to get the recommendations based on the criteria described here and an optional parameter of requestOptions that you can check out hereFor more details check out the official documentation of this method here
useAlgoliaRefBy calling this composable you have access to algoliasearch instance anywhere in your app
<script setup>const algolia = useAlgoliaRef()</script>useAlgoliaInitIndexUse this composable to initialize index you would like to search through. It accepts an index name as a parameter
<script setup>const algoliaIndex = useAlgoliaInitIndex('test')console.log(algoliaIndex.appId)</script>For more details about initializing index check out the official documentation here