Next.js Discord

Discord Forum

SWR error import

Answered
Common Loon posted this in #help-forum
Open in Discord
Common LoonOP
SWR is dead?
Answered by Asian black bear
You are trying to import it server-side which you can't. swr is a client-side library and can only be used in client-side code.
View full answer

5 Replies

Asian black bear
You are trying to import it server-side which you can't. swr is a client-side library and can only be used in client-side code.
Answer
Common LoonOP
can i add "use client"?
Asian black bear
Yes, you can define it within a file that is beyond that server/client boundary.
Common LoonOP
thanks a lot
problem solved