Open History to see the last commit
1# TanStack Solid Query Algolia Example
2β
3Searches products on Algolia as you type, with a debounced search term and paginated results loaded with an infinite query.
4β
5## How it works
6β
7- `src/services/products/queries.ts` defines `productsQueries.search(...)`, an `infiniteQueryOptions` factory keyed by `['products', 'search', indexName, query, hitsPerPage]`. It uses `skipToken` while the search term is empty, and `getNextPageParam` stops at the last page reported by Algolia.
8- `src/services/products/api.ts` calls Algolia's `searchSingleIndex` with the page number from `pageParam`.
9- `src/Search.tsx` debounces the input by 300 ms with `createDebouncedValue` from TanStack Pacer and passes the debounced term to `src/SearchResults.tsx`.
10- `src/SearchResults.tsx` passes the options to `useInfiniteQuery` with a 30-second `staleTime`, flattens `data.pages` into one list, and loads more results with `fetchNextPage` while `hasNextPage` is `true`.
11β
12To run this example:
13β
14- `npm install`
15- `npm run dev`