Next.js Discord

Discord Forum

Question about server component and client components

Answered
Cape lion posted this in #help-forum
Open in Discord
Avatar
Cape lionOP
Hi all 😄 I am new to Next.js
I have <Articles/> which is a server component that fetches articles from the server.
I am importing it inside of <Home/> which is a client component because I have a useEffect inside of it.
I keep getting this error:
Error: async/await is not yet supported in Client Components, only Server Components. This error is often caused by accidentally adding 'use client' to a module that was originally written for the server.

Can someone help me fix it?:D
Image
Answered by not-milo.tsx
Server components cannot be imported into client components. You can only pass them as props like you would with a context provider.
View full answer

5 Replies

Avatar
Server components cannot be imported into client components. You can only pass them as props like you would with a context provider.
Answer
Avatar
Here you can find a very good visualisation made by Alex Sidorenko on how you can compose client and server components together

https://twitter.com/asidorenko_/status/1694366373240062087?s=20
Avatar
Cape lionOP
Thank you @not-milo.tsx 😄
Avatar
No problem ✌️