Afosto Instant Search Client
This library is an Afosto search client plugin for the open-source InstantSearch.js library (powered by Algolia). With this plugin you can use the amazing widgets of the InstantSearch.js library, while communicating with the Afosto search API.
? Currently in development ?
Installation
Basic
# Install with Yarn
yarn add @afosto/instant-search-client instantsearch.js
# Install with NPM
npm install @afosto/instant-search-client instantsearch.js
React
# Install with Yarn
yarn add @afosto/instant-search-client react-instantsearch-dom
# Install with NPM
npm install @afosto/instant-search-client react-instantsearch-dom
Browser
This library supports the last two versions of major browsers (Chrome, Edge, Firefox, Safari).
<script src="https://cdn.jsdelivr.net/npm/@afosto/instant-search-client@latest/dist/afosto-instant-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js"></script>
Getting started
First you initialize the Afosto search client with your proxy key. This proxy key can be found in the Afosto app.
ES6
import { afostoInstantSearch } from '@afosto/instant-search-client';
const client = afostoInstantSearch('proxy-key');
CJS
const { afostoInstantSearch } = require('@afosto/instant-search-client');
const client = afostoInstantSearch('proxy-key');
Browser
const client = afostoInstantSearch('proxy-key');
Usage
Note: This library is a client for InstantSearch.js it does not contain any UI components by itself. You can use it with the InstantSearch.js library as shown below:
Basic
const client = afostoInstantSearch('proxy-key');
const search = instantsearch({
indexName: 'my-index',
searchClient: client,
});
search.start();
For more information check the InstantSearch.js documentation.
React
You can use the initialized Afosto client with the React InstantSearch library.
import { afostoInstantSearch } from '@afosto/instant-search-client';
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
const searchClient = afostoInstantSearch('proxy-key');
const App = () => (
<InstantSearch searchClient={searchClient} indexName="my-index">
<SearchBox />
<Hits />
</InstantSearch>
);
For more information check the React InstantSearch documentation.
Compatibility
- InstantSearch.js v4
- Node >= 12.10
License
This project is licensed under the terms of the MIT license.