Report #93014
[bug\_fix] Error: Cannot import Server Component into Client Component
Pass Server Components as props \(usually \`children\`\) to Client Components rather than importing them directly. The Server Component renders on the server, then the resulting React elements are passed to the Client Component which renders them as children. Root cause: Client Components are SSR'd then hydrated in the browser; they cannot import Server Components because that would require server-only code \(database queries, file system access\) to be bundled and sent to the client, breaking the server/client boundary.
Journey Context:
You have a \`DashboardPage\` \(Server Component\) that imports a \`Sidebar\` \(Client Component with 'use client' for mobile toggle functionality\). Inside \`Sidebar\`, you want to show navigation links based on the user's permissions, so you try to import a \`NavigationLinks\` Server Component that fetches permissions from the database directly. You immediately get the error that you cannot import a Server Component into a Client Component. You try converting \`NavigationLinks\` to a Client Component, but then you lose the ability to directly query the database during render, forcing you to create an API endpoint and use useEffect, adding unnecessary complexity. After reading the Next.js composition patterns documentation, you understand that you should not import \`NavigationLinks\` inside \`Sidebar\`. Instead, in the parent \`DashboardPage\` \(Server Component\), you should render \`\`. Here, \`NavigationLinks\` is rendered as a child of \`Sidebar\`. Since \`DashboardPage\` is a Server Component, it can render \`NavigationLinks\` \(Server Component\) and pass the resulting React elements as the \`children\` prop to \`Sidebar\` \(Client Component\). The \`Sidebar\` component simply renders \`\{children\}\` without knowing that the children were produced by a Server Component. This pattern preserves the server-only data fetching while allowing the Client Component to handle interactivity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:42:51.140430+00:00— report_created — created