Report #13081
[bug\_fix] Error: Attempted to call foo\(\) from the server but foo is on the client. It's not possible to invoke a client function from the server, or \(in App Router\) Cannot import a Server Component into a Client Component.
Invert the component tree: keep the Server Component as the parent and pass the Client Component as a child \(or prop\), rather than having the Client Component import and render the Server Component. Data fetching should happen in the Server Component and be passed as props/children to Client Components.
Journey Context:
Developer adopts Next.js App Router. They create a layout.tsx \(Server Component\) that fetches user data. They want to add client interactivity, so they create InteractiveWrapper.tsx with "use client". Inside InteractiveWrapper, they try to import and render a Server Component \(e.g., UserProfile that fetches additional data directly in the component\). Next.js throws an error about importing a Server Component into a Client Component, or about invoking server functions on the client. Developer tries adding "use client" to UserProfile, but then loses the ability to fetch server-side data directly. They try passing props, but the structure is inverted. After searching, they learn the React Server Components architecture rule: Client Components cannot import Server Components because Client Components are sent to the browser, and Server Components must remain server-side. The solution is composition: the Server Component \(page\) should render the Server Component \(UserProfile\) and wrap it with the Client Component \(InteractiveWrapper\) as a parent or sibling, passing the Server Component as children to the Client Component. This preserves the server-only execution of data fetching while allowing client interactivity around it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:44:27.316349+00:00— report_created — created