hydration the initial UI does not match what was rendered on the server with next-theme

big time next js noobie here, using next theme as my dark/light mode solution and it keeps giving me this error. my code:
7 Replies
kdiffin
kdiffinOP2y ago
also tried solving it like this, but it only works partially as the value for theme can be either "light" or "dark" depending on whats stored on localstorage.
niels
niels2y ago
That error is usually because of invalid html
kdiffin
kdiffinOP2y ago
it works when i remove that conditional
benton
benton2y ago
This is happening because you're rendering one theme on the server and another in the browser you need to render the same theme in both the server and browser
kdiffin
kdiffinOP2y ago
how can i do this?
benton
benton2y ago
Don't use those conditionals
kdiffin
kdiffinOP2y ago
alright

Did you find this page helpful?