React quick start
Integrate a search-as-you-type experience into your React app.
Integrate a search-as-you-type experience into your React app.
1. Create a React application
Create your React application using a Vite template:
2. Install the library of search components
Navigate to your React app and install react-instantsearch
, @meilisearch/instant-meilisearch
, and instantsearch.css
.
- React InstantSearch: front-end tools to customize your search environment
- instant-meilisearch: Meilisearch client to connect with React InstantSearch
- instantsearch.css (optional): CSS library to add basic styles to the search components
3. Initialize the search client
Use the following URL and API key to connect to a Meilisearch instance containing data from Steam video games.
4. Add the InstantSearch provider
<InstantSearch>
is the root provider component for the InstantSearch library. It takes two props: the searchClient
and the index name.
5. Add a search bar and list search results
Add the SearchBox
and InfiniteHits
components inside the InstantSearch
wrapper component. The Hits component accepts a custom Hit component via the hitComponent
prop, which allows customizing how each search result is rendered.
Import the CSS library to style the search components.
Use the following CSS classes to add custom styles to your components:
.ais-InstantSearch
, .ais-SearchBox
, .ais-InfiniteHits-list
, .ais-InfiniteHits-item
6. Start the app and search as you type
Start the app by running:
Now open your browser and navigate to your React app URL (e.g. localhost:3000
), and start searching.
Encountering issues? Check out the code in action in our live demo!
Next steps
Want to search through your own data? Create a project in the Meilisearch Dashboard. Check out our getting started guide for step-by-step instructions.
Was this page helpful?