algolia / algolia/instantsearch
Dynamic Code Evaluation error in Vercel Edge Runtime
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 553
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 51
Description
### 🐛 Current behavior
I'm currently using the `` 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](https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/#app-router-experimental).
Some details below:
**Dependencies:**
```json
"algoliasearch": "^4.23.3",
"next": "^14.2.4",
"react-instantsearch": "^7.11.2",
"react-instantsearch-nextjs": "^0.3.3"
```
**Error:**
```bash
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
- [X] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start with the reported import from react-instantsearch/dist/es/index.js in components/search/complex-doc-search/complex-doc-search.tsx, using the listed react-instantsearch, react-instantsearch-nextjs, and Next.js versions. Check the build under the Node.js runtime and compare it with the reported Edge Runtime error. Done means the app builds without the Dynamic Code Evaluation error in the stated configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100