Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstantSearch make the searchClient unusable for other mean in SSR #6576

Open
1 task done
Shywim opened this issue Feb 25, 2025 · 1 comment
Open
1 task done

InstantSearch make the searchClient unusable for other mean in SSR #6576

Shywim opened this issue Feb 25, 2025 · 1 comment
Labels
triage Issues to be categorized by the team

Comments

@Shywim
Copy link

Shywim commented Feb 25, 2025

🐛 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

  • I agree to follow this project's Code of Conduct
@Shywim Shywim added the triage Issues to be categorized by the team label Feb 25, 2025
@Haroenv
Copy link
Contributor

Haroenv commented Feb 25, 2025

I'm not sure how we could avoid this as notably algoliasearch v4 only accepts the flat parameters. As an initial workaround, you can use the "legacy search parameters" argument to client.search, which is the flat array.

TypeScript indeed won't warn about that, but at least it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues to be categorized by the team
Projects
None yet
Development

No branches or pull requests

2 participants