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

React InstantSearch NextJS not compatible with NextJS 15 (stable release as of 10/21): Not handling async request apis #6409

Open
1 task done
buyblvd-ryan opened this issue Oct 24, 2024 · 6 comments
Labels
triage Issues to be categorized by the team

Comments

@buyblvd-ryan
Copy link

🐛 Current behavior

NextJS 15 became the official release on Monday, but InstantSearch Next doesn't work with the new asynchronous request apis causing several errors. InstantSearchNext.tsx and useInstantSearchRouting.ts both access headers incorrectly. Didn't see any references to Next15 compatibility in any issues or PRs, so wanted to open this up for people in the same boat as me.

🔍 Steps to reproduce

  1. Setup NextJS project
  2. Use React InstantSearch NextJS
  3. Error!

Live reproduction

N/A

💭 Expected behavior

N/A

Package version

react-instantsearch-nextjs 0.3.15

Operating system

All

Browser

All

Code of Conduct

  • I agree to follow this project's Code of Conduct
@buyblvd-ryan buyblvd-ryan added the triage Issues to be categorized by the team label Oct 24, 2024
@RobinGiel
Copy link

these are the headers being used:
headers().get('x-nonce')
headers().get('x-forwarded-proto')
headers().get('host'). headers()

should be awaited before using its value. info: https://nextjs.org/docs/messages/sync-dynamic-apis

image

@jpedroschmitz
Copy link

Maybe will it be fixed here?

#6382

@RobinGiel
Copy link

Maybe will it be fixed here?

#6382

It's not there

@Haroenv
Copy link
Contributor

Haroenv commented Nov 5, 2024

We'd be happy to look into a solution for this, and also accept a community PR. For now it seemed complex as the places we're using the headers are synchronous and early in the life cycle, so it's not clear where it should become asynchronous

@jpedroschmitz
Copy link

It makes sense. Maybe the way to go with it is to pass headers as a prop to InstantSearchNext. I took a quick look, and I believe this could be the easiest way to go. I'm not sure if React.use() will work given the scenario, and I don't think we can make InstantSearchNext a server component, right @Haroenv?

@Haroenv
Copy link
Contributor

Haroenv commented Nov 12, 2024

The component indeed needs to be mounted client-side as well so it can't be server-only. Passing headers top-level could be an option. If you pass headers, the synchronous calls could be conditional and there won't be a warning anymore right?

If that works, we'd be happy to receive a pull request that accepts "static" headers as alternative to reading them synchronous already. Thanks!

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

4 participants