Can you import a Client Component inside a Server Component?
Yes. This is the normal pattern: a Server Component imports a "use client" component and renders it with serializable props. The Client Component is server-side rendered to HTML for the first load and hydrated in the browser.
What happens
- Next.js does not bundle the Server Component, but it does bundle the imported Client Component and its imports for the browser.
- In the RSC payload, the Client Component appears as a reference to its JavaScript module plus its props.
- On the client, React downloads that module and hydrates the HTML.
Rules
- Props must be serializable. You cannot pass
onClick={() => ...}from a Server Component; pass data, JSX or a Server Function instead. - The Client Component file must have
"use client"at the top (or be imported by a file that does). - Named and default exports both work.
Third-party components
Many UI libraries ship components that use hooks. If a library lacks the directive, importing it directly into a Server Component fails with a hooks error. Re-export it from your own file:
"use client"; export { Carousel } from "some-carousel";
Good practice
Import Client Components at the leaves and keep data fetching in the Server Component parent. A large interactive widget can be loaded lazily with next/dynamic inside a Client Component.
Code example
1// app/page.tsx - Server Component2import { Counter } from "./counter"; // "use client"3import { Carousel } from "./carousel"; // re-exported third-party client component4import { getSlides } from "@/lib/slides";56export default async function Home() {7 const slides = await getSlides();8 return (9 <main>10 <Counter start={5} /> {/* serializable prop */}11 <Carousel slides={slides} />12 {/* <Counter onChange={() => {}} /> Error: functions are not serializable */}13 </main>14 );15}1617// app/counter.tsx18// "use client";19// import { useState } from "react";20// export function Counter({ start }: { start: number }) {21// const [n, setN] = useState(start);22// return <button onClick={() => setN(n + 1)}>{n}</button>;23// }2425// app/carousel.tsx26// "use client";27// export { Carousel } from "acme-carousel";
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.