Fullstack CourseLearn by building
Back to week 4

Topic

Challenge: Server or Client?

Definition

A Server Component may render server-side data and compose Client Components, while browser interactivity must be isolated behind a Client Component boundary.

In simpler words

Keep the page shell on the server; make only the clicky leaf client-side.

The challenge prevents accidentally marking a whole route client-only because one child needs a button.

After this you can

  • Locate a Client Component boundary
  • Keep server-only code out of browser bundles

Find the smallest boundary

Definition

The "use client" directive marks a module and its imports as client-side, so it should appear only where browser APIs or interaction begin.

In simpler words

Move the interactive leaf, not the entire page, to the client.

Server Components can pass serializable props to Client Components.

A Client Component cannot import a server-only database or secret module.

Keep in mind

  • If the only event is a composer submit, the route shell does not need "use client".

Challenge lab

Bug report

A feed page imports a server-only environment helper after adding "use client" for a like button.

What is broken

The route was turned into a Client Component to make one button interactive.

Broken snippet

'use client';
import { serverOnlyConfig } from "@/lib/server-config";

export default function FeedPage() {
  return <button onClick={...}>Like</button>;
}

Pass criteria

  • Feed shell remains server-rendered
  • Button receives only serializable data and callbacks
  • No server-only import reaches the browser

Checking your session…

Choose the correct fix

Test

Check your understanding

At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥80% (enforced by the API) to save progress.

Checking your session…

15 questions · concept 5 · syntax 3 · practical 4 · logic 3

1. Next challenge focus?
Concept
2. Linking between challenge pages?
Syntax
3. Interactive widget in a server page?
Practical
4. Loading states?
Logic
5. Metadata for challenge pages?
Concept
6. Fetching for a challenge board?
Practical
7. Env usage?
Syntax
8. notFound in dynamic routes?
Logic
9. Challenge deploy smoke?
Concept
10. Which Next challenge mistake is common?
Practical
11. What does the interactive Filter need?
Conceptintermediate
export default function Page() {
  return <Filter onChange={setQ} />; // Filter uses useState
}
12. What common Next challenge mistake does this show?
Syntaxadvanced
'use client';
export default function Page() {
  return <article>{staticContent}</article>;
}
13. Where does params.id come from?
Practicalintermediate
// app/tickets/[id]/page.tsx
export default function Page({ params }) {
  return <h1>Ticket {params.id}</h1>;
}
14. What is the idiomatic Next handling here?
Logicadvanced
const ticket = await getTicket(id);
if (!ticket) { /* ??? */ }
15. What is the better internal-navigation choice?
Conceptintermediate
<a href="/tickets">Tickets</a>

Checking your session…