Skip to content

Failing to generate static pages with InstantSearchNext provider on demand #6555

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

Open
1 task done
AmeerSapadmi opened this issue Feb 6, 2025 · 3 comments
Open
1 task done
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks)

Comments

@AmeerSapadmi
Copy link

AmeerSapadmi commented Feb 6, 2025

🐛 Current behavior

Running a full build works as expected, but attempting to render a page on demand in NextJS results in a 500 error with the following message:

[Error]: Dynamic server usage: Route / couldn't be rendered statically because it used headers. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

🔍 Steps to reproduce

  1. Go to /1
  2. Observe the 500 error message

Live reproduction

https://codesandbox.io/p/devbox/dreamy-moon-92jc4w

💭 Expected behavior

On demand page generation in NextJS works without throwing any errors

Package version

next 15.0.4, react-instantsearch-nextjs 0.4.4, algoliasearch 5.17.1, react-instantsearch 7.13.8

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@AmeerSapadmi AmeerSapadmi added the triage Issues to be categorized by the team label Feb 6, 2025
@a-mitic-vegait
Copy link

As well as with this issue #6552 I am experiencing the same problem here.

@AmeerSapadmi
Copy link
Author

Hi, I just noticed the sandbox link was incorrect. I’ve updated it to the correct one now. Thanks for your help!

@dhayab dhayab added Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks) and removed triage Issues to be categorized by the team labels Apr 9, 2025
@dhayab
Copy link
Member

dhayab commented Apr 9, 2025

Hi, you can set the export const dynamic = 'force-static'; segment config at the top of your your [...slug]/page.tsx file. This will force headers() and useSearchParams() to return empty values when used during static prerendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks)
Projects
None yet
Development

No branches or pull requests

3 participants