0

I have a Next.js project using the App router.

One of my API routes wants to import a function "X" from a library that also happens to import another library that imports useEffect. Function X itself doesn't rely on useEffect, or any of React.

Because I'm in an API route on the server-side, I get a runtime ReactServerComponentsError

I'm not relying on that useEffect in any way, so how can I tell Next/React to ignore that error?

The error message:

ReactServerComponentsError:

You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122

0 Answers0