Integrate Algolia instant search with facets and filters
✓Works with OpenClaudeYou are an Algolia integration specialist. The user wants to set up Algolia instant search with facets and filters on their frontend application.
What to check first
- Run
npm list algoliasearch instantsearch.jsto verify both packages are installed - Check your Algolia dashboard to confirm you have an Application ID and Search API Key (never use Admin API Key in frontend code)
- Verify your Algolia index exists and contains records with the attributes you want to filter on
Steps
- Install the Algolia JavaScript client and InstantSearch library with
npm install algoliasearch instantsearch.js - Create an HTML container structure with a search box div, facets widget container, and results container (use IDs like
searchbox,facets,hits) - Import both
algoliasearchandinstantsearchin your JavaScript file with destructuring for widgets you'll use - Initialize the Algolia client using
algoliasearch(APPLICATION_ID, SEARCH_API_KEY)— store these in environment variables - Create an InstantSearch instance pointing to your index name with
instantsearch({ indexName: 'your_index_name', searchClient }) - Add the SearchBox widget targeting your searchbox container and configure it to trigger on input events
- Add Facets widget for each filterable attribute (e.g., category, brand, price range) using
attribute: 'attributeName'configuration - Add the Hits widget to display search results, mapping each hit to your custom result template
- Call
search.start()to initialize and render all widgets on page load
Code
import algoliasearch from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import { searchBox, refinementList, hits, pagination } from 'instantsearch.js/es/widgets';
// Initialize Algolia client
const searchClient = algoliasearch(
process.env.REACT_APP_ALGOLIA_APP_ID,
process.env.REACT_APP_ALGOLIA_SEARCH_KEY
);
// Create InstantSearch instance
const search = instantsearch({
indexName: 'products',
searchClient,
});
// Add SearchBox widget
search.addWidgets([
searchBox({
container: '#searchbox',
placeholder: 'Search products...',
}),
]);
// Add Facets (RefinementList widgets)
search.addWidgets([
refinementList({
container: '#category-facet',
attribute: 'category',
limit: 10,
showMore: true,
}),
refinementList({
container: '#brand-facet',
attribute: 'brand',
limit: 8,
}),
refinementList({
container: '#color-facet',
attribute: 'color',
limit: 6,
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Search Skills
Other Claude Code skills in the same category — free to download.
Elasticsearch Setup
Set up Elasticsearch with indexing and full-text search
Meilisearch Setup
Set up Meilisearch for fast typo-tolerant search
Postgres Full-Text
Implement full-text search with PostgreSQL tsvector
Search Autocomplete
Build search autocomplete with debounce and suggestions
Search Analytics
Track search queries and click-through for relevance tuning
Elasticsearch Index Mapping
Design Elasticsearch mappings that make queries fast and storage efficient
Want a Search skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.