0
0
NextJSframework~5 mins

Server and client component composition in NextJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Server Component in Next.js?
A Server Component runs only on the server. It can fetch data securely and render HTML before sending it to the browser. It does not include client-side JavaScript by default.
Click to reveal answer
beginner
What is a Client Component in Next.js?
A Client Component runs in the browser. It can use React hooks like useState and handle user interactions. It includes JavaScript sent to the client.
Click to reveal answer
beginner
How do you mark a component as a Client Component in Next.js?
Add the directive 'use client' at the top of the component file. This tells Next.js to bundle it for the browser.
Click to reveal answer
intermediate
Why compose Server and Client Components together?
Composing them lets you fetch data and render static parts on the server, while interactive parts run on the client. This improves performance and user experience.
Click to reveal answer
intermediate
Can a Server Component import a Client Component in Next.js?
Yes, a Server Component can import and render a Client Component. But a Client Component cannot import a Server Component.
Click to reveal answer
Which directive marks a component as a Client Component in Next.js?
A'server only'
B'use server'
C'client only'
D'use client'
Where does a Server Component run?
ABoth server and browser
BIn the browser
COn the server
DOnly during build time
Which of these can a Client Component do that a Server Component cannot?
AUse React hooks like useState
BRender HTML
CFetch data securely
DRun without JavaScript
Can a Client Component import a Server Component?
AYes, always
BNo, never
COnly if marked with 'use client'
DOnly in development mode
What is a benefit of composing Server and Client Components?
ABetter SEO and interactivity
BFaster server startup
CNo JavaScript sent to client
DSimpler code without imports
Explain how Server and Client Components work together in Next.js and why this composition is useful.
Think about where code runs and what each component type can do.
You got /5 concepts.
    Describe how to create a Client Component in Next.js and what special directive is needed.
    Focus on the special string at the top of the file.
    You got /4 concepts.