Next.js Discord

Discord Forum

SWR error import

Answered
Common Loon posted this in #help-forum
Open in Discord
Avatar
Common LoonOP
SWR is dead?
Image
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

Avatar
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
Avatar
Common LoonOP
can i add "use client"?
Avatar
Asian black bear
Yes, you can define it within a file that is beyond that server/client boundary.
Avatar
Common LoonOP
thanks a lot
problem solved