Next.js · Middle · Question 47 of 75

Where does a client component's code run on the first page load?

Explanation

'use client' doesn't mean "client only": the component is prerendered to HTML on the server and then hydrated. That's why you can't access window during render without checks - use effects or next/dynamic with ssr: false.

Further reading

Problem with a question

Next.js · Middle · question 47

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz