Skip to content
Learn Netverks

Lesson

Step 15/36 42% through track

composition-patterns

Server/client composition

Last reviewed May 28, 2026 Content v20260528
Track mode
client_nextjs
Means
In-browser Next.js (client components)
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Server/client composition: the concepts, APIs, and habits you need before advancing in Next.js.

Without Server/client composition, you will struggle to read or extend Next.js codebases and playground exercises.

You will apply Server/client composition in contexts like: Marketing sites, dashboards, e-commerce, and Vercel-style deployments that need hybrid static + dynamic pages.

Write TSX for Client Components, click Run—React 18 CDN + in-browser TSX compile; use client/server lessons explain App Router concepts; mountApp renders interactive UI; printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

The most productive Next.js apps compose Server and Client Components: server parents fetch and pass serializable props; client children handle interactivity. Think “server shell, client islands.”

Pattern: server page + client widget

// app/page.tsx — Server Component
import { LikeButton } from './like-button';

export default async function Page() {
  const post = await getPost();
  return (
    <article>
      <h1>{post.title}</h1>
      <p>{post.body}</p>
      <LikeButton initialLikes={post.likes} postId={post.id} />
    </article>
  );
}
// like-button.tsx
'use client';
export function LikeButton({ initialLikes, postId }: Props) {
  const [likes, setLikes] = useState(initialLikes);
  // ...
}

Children slot pattern

A Client Component can wrap {children} passed from a Server Component—static server content streams through the client shell (e.g. modal layout around server-rendered detail).

Anti-patterns

  • Marking entire layouts 'use client' by default
  • Fetching in useEffect when the server could load data first
  • Passing non-serializable props (class instances, functions) across the boundary

Self-check

  1. Who should fetch post data in the pattern above?
  2. What props are safe to pass from server to client?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Children as slots?
  • Server wraps client how?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump