Make sure you’ve installed InstantSearch before following this guide.
Choose Your Framework
Select the framework you’re using:- JavaScript
- React
- Vue
JavaScript Quick Start
Build a search UI with vanilla JavaScript.Complete Example
Here’s the complete JavaScript code:Testing Your Search
Once you’ve implemented the code:Verify the search works
Open your browser and try:
- Typing in the search box - results should update instantly
- Clicking category filters - results should filter accordingly
- Using pagination - navigate through result pages
What’s Happening?
Let’s break down the key parts:- Search Client - Connects to your Algolia application using the lite client (optimized for search)
- InstantSearch Instance - The main container that manages the search state
- Widgets/Components - UI elements that render and interact with the search:
SearchBox- Input field for search queriesHits- Displays search resultsRefinementList- Faceted filter for attributesPagination- Navigate through pagesConfigure- Set search parameters
- Highlight - Highlights matching terms in results
Customization
Now that you have a basic search working, you can customize it:Add More Widgets
Explore the widget library to add features like:- Range Sliders - Filter by price or numeric ranges
- Sort By - Let users change result ordering
- Current Refinements - Show active filters with clear buttons
- Stats - Display result count and search time
- Clear Refinements - Reset all filters at once
Style Your Search
Customize the appearance:- Override CSS classes (all widgets use BEM naming)
- Create custom templates for results
- Use your own CSS framework
- Build custom widgets
Configure Search Behavior
Adjust how search works:- Set ranking rules
- Configure typo tolerance
- Add custom ranking
- Set searchable attributes
Next Steps
Now that you have a working search, explore these topics:Widget Showcase
Browse all available widgets and their options
Customization Guide
Learn how to style and customize your search UI
Server-Side Rendering
Implement SSR for better SEO and performance
Routing
Sync search state with the URL for shareable links
Troubleshooting
Search Results Not Appearing
- Verify your Application ID and API Key are correct
- Check that your index name matches exactly
- Ensure your index has data
- Check the browser console for errors
Widgets Not Rendering
- Verify HTML containers exist (JavaScript version)
- Check that you called
search.start()(JavaScript version) - Ensure the InstantSearch component wraps all widgets (React/Vue)
TypeScript Errors
- Install the correct type packages for your Algolia client version
- Import the
Hittype frominstantsearch.js - Type your hit data properly