algolia / react-instantsearch

⚑️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

React Instantsearch Hooks: SSR not working on v6.27.0 #3511

Closed francisconeves97 closed 2 years ago

francisconeves97 commented 2 years ago

πŸ› Bug description

SSR with Next.js is not working on the latest version of react-instantsearch-hooks-web and react-instantsearch-hooks-server (6.27.0). Every element that is rendered inside the <InstantSearch /> component is only rendered on the client side,

πŸ” Bug reproduction

Steps to reproduce the behavior:

  1. Clone the hooks-ssr example: https://github.com/algolia/react-instantsearch/tree/v6.22.0/examples/hooks-ssr
  2. Change the react-instantsearch-hooks, react-instantsearch-hooks-server and react-instantsearch-hooks-web dependencies version from 6.22.0 to 6.27.0
  3. Install the npm dependencies
  4. Start the server
  5. Verify that no search results were server side rendered by checking the html source

Live reproduction:

https://codesandbox.io/s/github/algolia/react-instantsearch/tree/v6.27.0/examples/hooks-next?file=/package.json

πŸ’­ Expected behavior

The widgets inside the <InstantSearch /> should be server side rendered

Environment

Additional context

Tried to downgrade to version 6.26.0 and the search results are server side rendered, so the issue should have been introduced on the last release

dominiksipowicz commented 2 years ago

I can confirm and reproduce the SSR bug. It's working on the previous version 6.26.0

It can be tested by simply disabling JavaScript in Google Chrome (Settings -> Prefrences -> Debugger -> Disable JavaScript)

Haroenv commented 2 years ago

This is very surprising, as on a quick glance, the only relevant change happened in 6.25.0 with https://github.com/algolia/react-instantsearch/commit/0a13867f7dd5a8a18e0957b2072bbde3b02d6490, otherwise also InstantSearch.js was updated between 6.26.0 and 6.27.0

Thanks for reporting this, we are investigating further!

francoischalifour commented 2 years ago

The issue comes from #3489. We identified the problem and have a fix for this. We're currently writing more integration tests to make sure this doesn't happen again. You can expect a fix in the next minor version, we'll ping you here.

Thank you for reporting!

dominiksipowicz commented 2 years ago

thanks @francoischalifour, awesome!

francoischalifour commented 2 years ago

The SSR fix was released in v6.28.0. Thank you all!

francisconeves97 commented 2 years ago

Amazing, thank you!