niceone-algolia
v0.1.0
Published
Simple wrapper/integration for Algolia InstantSearch
Downloads
4
Readme
niceone-algolia
Simple wrapper/integration for Algolia InstantSearch.
Setup
- Add
niceone-algolia
dependency to your project
yarn add niceone-algolia # or npm install niceone-algolia
- Add
niceone-algolia
to themodules
section ofnuxt.config.js
{
modules: [
'niceone-algolia'
],
publicRuntimeConfig: {
algolia: {
applicationId: [YOUR APPLICATION ID],
apiKey: [YOUR API KEY],
}
}
}
Usage
Component
asyncData
async asyncData ({ $algolia }) {
const index = $algolia.initIndex('instant_search');
const results = await index.search('Google');
return results;
}
methods
/created
/mounted
/etc
methods: {
async fetchResults(query) {
const index = this.$algolia.initIndex('instant_search');
this.results = await index.search(query);
}
}
Store actions (including nuxtServerInit
)
// In store
{
actions: {
async fetchGoogleProducts ({ commit }) {
const index = this.$algolia.initIndex('instant_search');
const products = await index.search('Google');
commit('SET_PRODUCTS', products);
}
}
}
Development
- Clone this repository
- Install dependencies using
yarn install
- Start development server using
yarn dev