Skip to main content
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.

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.
React app search UI with a search bar at the top and search results for a few video games
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.