Import a client component into server
Unanswered
Bucovina Shepherd Dog posted this in #help-forum
Bucovina Shepherd DogOP
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 -
I'm not sure if it is correct
const InputField = dynamic(() => import('@/components/InputField'), { ssr: false });
I'm not sure if it is correct
3 Replies
Bucovina Shepherd DogOP
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)
That’s correct, but it’s only needed if that Client Component is using Client Only supported APIs like the
If your client component has “use client” and you’re getting a hydration error, then yes, use
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/>}
For client components that do not have conflicts with Client Only APIs, that’s not necessarily, unless you want to delay the rendering of the component to only happen on the client for some reason.