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
kdiffin15mo 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
niels15mo ago
That error is usually because of invalid html
kdiffin
kdiffin15mo ago
it works when i remove that conditional
b_e_n_t_e_n
b_e_n_t_e_n15mo 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
kdiffin15mo ago
how can i do this?
b_e_n_t_e_n
b_e_n_t_e_n15mo ago
Don't use those conditionals
kdiffin
kdiffin15mo ago
alright