#Import a client component into server

1 messages · Page 1 of 1 (latest)

drowsy glen
#

Hey guys! I am currently learning Next.js and i wonder if u could import my client component into another server component. Chat GPT is telling me to use ssr: false like this - const InputField = dynamic(() => import('@/components/InputField'), { ssr: false });
I'm not sure if it is correct

eternal veldtBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

drowsy glen
#

I got my client component as a input, i use it on my main generator page but i also want to use it somewhere else (for instance in my chat page which is a server component atm)

plucky sandal
#

That’s correct, but it’s only needed if that Client Component is using Client Only supported APIs like the window object (document, local storage, etc) or some APIs like Date, random() and a couple more.

If your client component has “use client” and you’re getting a hydration error, then yes, use dynamic and you can even provide a fallback while the Client is first mounting the component {ssr : false, loading : <Skeleton/>}