Next.js · Senior · Question 67 of 75

How do you apply a saved theme or locale-specific date before the first paint without a hydration error or flash?

Explanation

The server can't know client preferences. useEffect causes a flash, and rendering client values during hydration causes a mismatch; an inline script runs before paint.

Further reading

Problem with a question

Next.js · Senior · question 67

Test yourself

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

Take this quiz