Preparing your workspace
Next.js App Router supports server-first components, while client components are used when browser-side interactivity or client-only APIs are required.
Server Components can run on the server and can access server-side resources without sending their implementation to the browser as client JavaScript. Client Components are marked with 'use client' and are used when a component needs state, event handlers, effects, or browser APIs. Keeping components server-side when possible can reduce browser JavaScript and keep sensitive operations on trusted server boundaries. The goal is not to use one type everywhere, but to place each responsibility in the correct environment.
A course page can load course data on the server while an interactive quiz component runs on the client.
export default async function CoursePage() {
const course = await getCourse();
return (
<main>
<h1>{course.title}</h1>
<Quiz />
</main>
);
}
// Quiz.tsx
'use client';
import { useState } from 'react';The course data can be loaded on the server while the interactive quiz uses client-side state.