algolia / algolia/instantsearch

InstantSearch make the searchClient unusable for other mean in SSR

Open
#6,576 1 comment 0 reactions 0 assignees View on GitHub
triage
Dominant language
TypeScript
Stars
4.1k
Forks
553
Avg merge
1d 11h
Merged PRs (30d)
51

Description

### 🐛 Current behavior

After the searchClient has been altered in `hydrateSearchClient`, the client can't be used in the way algolia search client should be expecting params, because it expected "flat" parameters along `indexName`, while the modification made by `hydrateSearchClient` expect everything to be nested in a `params` object.

### 🔍 Steps to reproduce

Here's a reproduction repo: https://github.com/Shywim/instantsearch-nextjs-params

Note the additional search done after the state has been rendered on the server: https://github.com/Shywim/instantsearch-nextjs-params/blob/fd5994ab03c4a1f3ea36689f8dbe0a8f5b5b2c9d/src/pages/index.tsx#L149-L151

### Live reproduction

https://codesandbox.io/p/github/Shywim/instantsearch-nextjs-params/main

### 💭 Expected behavior

We should be able to use the searchClient after it has been passed to InstantSearch.

### Package version

instantsearch.js 7.15.3, algoliasearch 5.20.3

### Operating system

_No response_

### Browser

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction and inspect the additional search in src/pages/index.tsx at lines 149-151, then trace how hydrateSearchClient alters the client during SSR. Reproduce the failure with the documented package versions. Done means the client remains usable for the flat parameters expected by the Algolia search client after it has been passed to InstantSearch.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
frontend, search, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.