algolia / instantsearch

⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.59k stars 503 forks source link

Dynamic Code Evaluation error in next.js #6249

Open TariqSaiyad opened 1 week ago

TariqSaiyad commented 1 week ago

🐛 Current behavior

I'm currently using the <InstantSearchNext> component in next.js for search, but my app won't build due to a Dynamic Code Evaluation error. I've made sure that the component has "use client" at the top and that the route segment is set to force-dynamic as per the docs.

Some details below:

Dependencies:

"algoliasearch": "^4.23.3",
"next": "^14.2.4",
"react-instantsearch": "^7.11.2",
"react-instantsearch-nextjs": "^0.3.3"

Error:

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation

The error was caused by importing 'react-instantsearch/dist/es/index.js' in './components/search/complex-doc-search/complex-doc-search.tsx'.

🔍 Steps to reproduce

I cannot share the project code as it is a private repo.

Live reproduction

cannot reproduce

💭 Expected behavior

The search should run as expected, I'm not deploying to the edge runtime, only in the nodejs runtime.

Package version

react-instantsearch 7.11.2, react-instantsearch-nextjs 0.3.3, next 14.2.4

Operating system

No response

Browser

No response

Code of Conduct