Next.js Discord

Discord Forum

I get an error if i try to put a client component into a server component

Answered
Arboreal ant posted this in #help-forum
Open in Discord
Arboreal antOP
Why can't i put a client component into a server component? i am importing the client component
import ServerList from "./components/ServerList";

import Head from 'next/head';
import { fetchServers } from "./actions/fetchServers";

export default async function Home() {

  const servers = await fetchServers(1)


  return (
    <div className="home">
      <ServerList searchQuery={ servers } />
    </div>
  );
}
i get the error
You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
Answered by joulev
does the components/ServerList.js file have "use client" on the top?
View full answer

5 Replies