examples/solid/algolia
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Algolia Example#
Searches products on Algolia as you type, with a debounced search term and paginated results loaded with an infinite query.
How it works#
src/services/products/queries.tsdefinesproductsQueries.search(...), aninfiniteQueryOptionsfactory keyed by['products', 'search', indexName, query, hitsPerPage]. It usesskipTokenwhile the search term is empty, andgetNextPageParamstops at the last page reported by Algolia.src/services/products/api.tscalls Algolia'ssearchSingleIndexwith the page number frompageParam.src/Search.tsxdebounces the input by 300 ms withcreateDebouncedValuefrom TanStack Pacer and passes the debounced term tosrc/SearchResults.tsx.src/SearchResults.tsxpasses the options touseInfiniteQuerywith a 30-secondstaleTime, flattensdata.pagesinto one list, and loads more results withfetchNextPagewhilehasNextPageistrue.
To run this example:
npm installnpm run dev