Before you begin
This quickstart requires:- Basic JavaScript knowledge.
- Node.js version 16 or later with npm version 5.2 or later.
Quickstart
In this quickstart, you’ll add an Algolia search interface to some starter code. The code:- Displays and formats a search box and results
- Uses InstantSearch’s pre-built UI components (widgets) to filter results
Open CodeSandbox
Run and edit the InstantSearch.js quickstart example in CodeSandbox.
Explore source code
Browse the source for the InstantSearch.js quickstart example on GitHub.
Add starter code
To generate some starter code, use the This command creates a folder structure on your machine:
create-instantsearch-app tool.
It provides the data, all necessary code, and predefined credentials ( and ).In a terminal, paste:Command line
Add the search UI
-
In
index.html, remove the<header>, and replace<div class="container">with:HTML -
Open
src/app.cssand replace its content with:
CSS
Run the app
-
In your terminal, type:
Command line
-
Open your browser and go to http://localhost:3000. The app displays the search box, results, and pagination components.

Add filters and settings
-
Open
index.htmland update it to:HTML -
Open
src/app.js, and add widgets to these placeholders:JavaScript
Create a two-column layout
The widgets come with a predefined style but you can customize it.
- Open
src/app.cssand update it to the following to apply a two-column layout:
CSS
-
In your browser, after a page refresh, the layout includes a Brands .

Format search results
Open the
src/app.js and replace the content of the hits widget with:JavaScript
The widgets
This quickstart uses several InstantSearch widgets:instantsearchis the root InstantSearch.js component. You must wrap all other widgets inside this component.searchBoxdisplays a search box for users to type queries into.hitsdisplays the results from Algolia, based on the .paginationadds navigation controls to browse through pages of results.clearRefinementsdisplays a button that clears the current refinements.refinementListdisplays a list of brands that users can use to filter the search.configurepasses search parameters. In this quickstart, it setshitsPerPageto 8.
Next steps
Instead of the credentials fromcreate-instantsearch-app,
use your own Algolia credentials.
You can send your own data or a sample dataset to Algolia using the JavaScript API client that comes preinstalled with create-instantsearch-app.
Then, configure the index with the JavaScript API client.
For example, to configure the sample dataset,
use the following code:
JavaScript
