Awesome
<p align="center"> <img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_react.svg" alt="Meilisearch-React" width="200" height="200" /> </p> <h1 align="center">Meilisearch React</h1> <h4 align="center"> <a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> | <a href="https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-react">Meilisearch Cloud</a> | <a href="https://www.meilisearch.com/docs">Documentation</a> | <a href="https://discord.meilisearch.com">Discord</a> | <a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> | <a href="https://www.meilisearch.com">Website</a> | <a href="https://www.meilisearch.com/docs/faq">FAQ</a> </h4> <p align="center"> <a href="https://github.com/meilisearch/meilisearch-react/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a></p> <p align="center">ā” How to integrate a front-end search bar in your React application using Meilisearch</p>Meilisearch is an open-source search engine. Discover what Meilisearch is!
This repository describes the steps to integrate a relevant front-end search bar with a search-as-you-type experience!
ā” Supercharge your Meilisearch experience
Say goodbye to server deployment and manual updates with Meilisearch Cloud. Get started with a 14-day free trial! No credit card required.
Installation
To integrate a front-end search bar, you need to install two packages:
- the open-source React InstantSearch library powered by Algolia that provides all the front-end tools you need to highly customize your search bar environment.
- the Meilisearch client instant-meilisearch to establish the communication between your Meilisearch instance and the React InstantSearch library.<br> Instead of reinventing the wheel, we have opted to reuse the InstantSearch library for our own front-end tooling. We will contribute upstream any improvements that may result from our adoption of InstantSearch.
Run:
yarn add react-instantsearch @meilisearch/instant-meilisearch
# or
npm install react-instantsearch @meilisearch/instant-meilisearch
# or
pnpm add react-instantsearch @meilisearch/instant-meilisearch
NB: If you don't have any Meilisearch instance running and containing your data, you should take a look at this getting started page.
Getting Started
Thanks to the open-source React InstantSearch library, you can add these components to your application:
import React from 'react';
import { InstantSearch, SearchBox, Hits, Highlight } from 'react-instantsearch';
import { instantMeiliSearch } from '@meilisearch/instant-meilisearch';
const { searchClient } = instantMeiliSearch(
'https://ms-adf78ae33284-106.lon.meilisearch.io',
'a63da4928426f12639e19d62886f621130f3fa9ff3c7534c5d179f0f51c4f303'
);
const App = () => (
<InstantSearch
indexName="steam-video-games"
searchClient={searchClient}
>
<SearchBox />
<Hits hitComponent={Hit} />
</InstantSearch>
);
const Hit = ({ hit }) => <Highlight attribute="name" hit={hit} />;
export default App
š For a full getting started example, please take a look at this CodeSandbox:
š” If you have never used React InstantSearch before, we recommend reading this getting started documentation.
Customization and Documentation
- The open-source React InstantSearch library is widely used and well documented in the Algolia documentation. It provides all the widgets to customize and improve your search bar environment in your React application.
- The instant-meilisearch documentation to add some customization.
- The Meilisearch documentation.
Meilisearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.