React·100 questions

Why does hydration mismatch happen and how to fix it?

Answer
Different HTML on server and client.
Reasons: time, random, access to window, conditional branches.
Use client-only rendering via useEffect or dynamic import.
Keep data consistent (prefetch).
Check environment (typeof window).
Was this answer helpful?

More questions in this topic

Related questions from other topics